This commit is contained in:
2026-02-03 15:31:29 +05:00
commit 326c677e8d
2800 changed files with 1489388 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
<?php
namespace App\Http\Requests\Api\System\VersionManagement;
use App\Models\System\Settings\OS;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class CheckForUpdateRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array|string>
*/
public function rules(): array
{
return [
/** @example 1.0.0 */
'version' => ['required', 'string', 'max:255'],
/** @example ios */
'os' => ['required', 'string', 'max:255', Rule::in(array_keys(OS::apps()))],
];
}
/**
* Get the error messages for the defined validation rules.
*
* @return array<string, string>
*/
public function messages(): array
{
return [
'os.in' => sprintf('Valid sources: %s', implode(', ', array_keys(OS::apps()))),
];
}
}

View File

@@ -0,0 +1,37 @@
<?php
namespace App\Http\Requests\Api\V1\Auth;
use App\Rules\VerificationRule;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class AuthLoginRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array|string>
*/
public function rules(): array
{
return [
/**
* @example 61929248
*/
'phone_number' => ['required', 'integer', 'between:61000000,71999999', Rule::exists('users', 'phone_number')],
];
}
/**
* Get the error messages for the defined validation rules.
*
* @return array<string, string>
*/
public function messages(): array
{
return [
'phone_number.exists' => __('User with this phone number does not exist'),
];
}
}

View File

@@ -0,0 +1,29 @@
<?php
namespace App\Http\Requests\Api\V1\Auth;
use App\Rules\VerificationRule;
use Illuminate\Foundation\Http\FormRequest;
class AuthVerifyRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array|string>
*/
public function rules(): array
{
return [
/**
* @example 61929248
*/
'phone_number' => ['required', 'integer', 'between:61000000,65999999'],
/**
* @example 99934
*/
'code' => ['required', 'integer', new VerificationRule($this->phone_number)],
];
}
}

View File

@@ -0,0 +1,22 @@
<?php
namespace App\Http\Requests\Api\V1\Brand;
use App\Models\Ecommerce\Product\Brand\Brand;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class BrandIndexRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'type' => ['nullable', 'string', Rule::in(Brand::types())],
];
}
}

View File

@@ -0,0 +1,33 @@
<?php
namespace App\Http\Requests\Api\V1\Brand;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class BrandProductsRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'lang' => ['nullable', 'string', Rule::in(array_keys(config('app.locales')))],
'perPage' => ['nullable', 'integer'],
];
}
/**
* Handle a passed validation attempt.
*/
protected function passedValidation(): void
{
$this->merge([
'lang' => $this->lang ?: config('app.locale'),
'perPage' => $this->perPage ?: 6,
]);
}
}

View File

@@ -0,0 +1,21 @@
<?php
namespace App\Http\Requests\Api\V1\Cart;
use Illuminate\Foundation\Http\FormRequest;
class CartAddProductRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array<string, array>
*/
public function rules(): array
{
return [
'product_id' => ['required', 'integer', 'exists:products,id'],
'quantity' => ['nullable', 'integer'],
];
}
}

View File

@@ -0,0 +1,20 @@
<?php
namespace App\Http\Requests\Api\V1\Cart;
use Illuminate\Foundation\Http\FormRequest;
class CartRemoveRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'product_id' => ['required', 'integer', 'exists:products,id'],
];
}
}

View File

@@ -0,0 +1,22 @@
<?php
namespace App\Http\Requests\Api\V1\Cart;
use App\Rules\ProductStockIsAvailable;
use Illuminate\Foundation\Http\FormRequest;
class CartStoreRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'product_id' => ['required', 'integer', new ProductStockIsAvailable($this->product_quantity)],
'product_quantity' => ['required', 'integer', 'min:1'],
];
}
}

View File

@@ -0,0 +1,21 @@
<?php
namespace App\Http\Requests\Api\V1\Category;
use Illuminate\Foundation\Http\FormRequest;
class CategoryIndexRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'type' => ['nullable', 'string', 'in:root,tree'],
'group' => ['nullable', 'string', 'in:market'],
];
}
}

View File

@@ -0,0 +1,52 @@
<?php
namespace App\Http\Requests\Api\V1\Forms\ContactUS;
use App\Models\System\Settings\OS;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class ContactUSStoreRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'phone' => ['required', 'integer', 'between:61000000,71999999'],
'title' => ['required', 'string', 'max:255'],
'content' => ['required', 'string', 'max:1000'],
'type' => ['required', 'string', Rule::in(OS::MOBILE_APP, OS::MOBILE_ADMIN)],
];
}
/**
* Body Parameters for scribe
*
* @return array<string, array<string, string>>
*/
public function bodyParameters(): array
{
return [
'phone' => [
'description' => 'Phone number',
'example' => '61929248',
],
'title' => [
'description' => 'Message title',
'example' => 'Hello',
],
'content' => [
'description' => 'Message content',
'example' => 'Awesome JOB',
],
'type' => [
'description' => 'From where?',
'example' => 'mobile_app',
],
];
}
}

View File

@@ -0,0 +1,20 @@
<?php
namespace App\Http\Requests\Api\V1\Forms\Newsletter;
use Illuminate\Foundation\Http\FormRequest;
class NewsletterSubscriptionStoreRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'email' => ['required', 'email', 'max:255'],
];
}
}

View File

@@ -0,0 +1,33 @@
<?php
namespace App\Http\Requests\Api\V1\Product;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class BasicProductIndexRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'lang' => ['nullable', 'string', Rule::in(array_keys(config('app.locales')))],
'perPage' => ['nullable', 'integer'],
];
}
/**
* Handle a passed validation attempt.
*/
protected function passedValidation(): void
{
$this->merge([
'lang' => $this->lang ?: config('app.locale'),
'perPage' => $this->perPage ?: 6,
]);
}
}

View File

@@ -0,0 +1,20 @@
<?php
namespace App\Http\Requests\Api\V1\Product;
use Illuminate\Foundation\Http\FormRequest;
class ProductCommentStore extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'comment' => ['required', 'string', 'max:255'],
];
}
}

View File

@@ -0,0 +1,33 @@
<?php
namespace App\Http\Requests\Api\V1\Product;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class ProductIndexRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'lang' => ['nullable', 'string', Rule::in(array_keys(config('app.locales')))],
'perPage' => ['nullable', 'integer'],
];
}
/**
* Handle a passed validation attempt.
*/
protected function passedValidation(): void
{
$this->merge([
'lang' => $this->lang ?: config('app.locale'),
'perPage' => $this->perPage ?: 6,
]);
}
}

View File

@@ -0,0 +1,37 @@
<?php
namespace App\Http\Requests\Api\V1\Product\Review;
use App\Models\System\Settings\OS;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class ProductReviewStore extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'rating' => ['required', 'numeric', 'max:5'],
'title' => ['required', 'string', 'max:255'],
'content' => ['nullable', 'string', 'max:255'],
'source' => ['required', 'string', Rule::in(array_keys(OS::apps()))],
];
}
/**
* Get the error messages for the defined validation rules.
*
* @return array<string, string>
*/
public function messages(): array
{
return [
'source.in' => sprintf('Valid sources: %s', implode(', ', array_keys(OS::apps()))),
];
}
}

View File

@@ -0,0 +1,22 @@
<?php
namespace App\Http\Requests\Api\V1\Product\Review;
use Illuminate\Foundation\Http\FormRequest;
class ProductReviewUpdate extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'rating' => ['required', 'numeric', 'max:5'],
'title' => ['required', 'string', 'max:255'],
'content' => ['nullable', 'string', 'max:255'],
];
}
}

View File

@@ -0,0 +1,102 @@
<?php
namespace App\Http\Requests;
use App\Models\Ecommerce\Product\Order\Payment\OrderPayment;
use App\Models\Ecommerce\Product\Order\Shipping\OrderShipping;
use App\Models\Ecommerce\Product\Order\Status\OrderStatus;
use App\Models\System\Settings\Location\Region;
use App\Models\System\Settings\OS;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Str;
use Illuminate\Validation\Rule;
class CheckoutOrderRequest extends FormRequest
{
/**
* Configure the validator instance.
*
* @param \Illuminate\Validation\Validator $validator
*/
public function withValidator($validator): void
{
$validator->after(function ($validator) {
if (auth()->user()->carts->count() == 0) {
$validator->errors()->add('user_without_product_in_cart', 'user has no product in his cart');
}
});
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, mixed>
*/
public function rules(): array
{
return [
'customer_name' => ['required', 'string', 'max:255'],
'customer_phone' => ['required', 'integer', 'between:61000000,71999999'],
'customer_address' => ['required', 'string', 'max:255'],
'shipping_method' => ['required', 'string', 'max:255', Rule::in(array_keys(OrderShipping::values()))],
'payment_type_id' => ['required', Rule::in(array_keys(OrderPayment::values()))],
'notes' => ['nullable', 'string', 'max:255'],
'delivery_time' => ['nullable', 'string', 'max:255', Rule::in(array_keys(OrderShipping::times()))],
'delivery_at' => ['nullable', 'string', 'max:255', 'date'],
'region' => ['required', 'string', 'max:255', Rule::in(array_keys(Region::values()))],
'province_id' => ['nullable', Rule::when($this->region !== Region::AG, [
'integer', 'exists:provinces,id',
])],
'source' => ['nullable', 'string', 'in:site,mobile_app'],
'cart_number' => ['nullable', 'integer'],
'cart_expiration_date' => ['nullable'],
'cart_user_name' => ['nullable', 'string'],
'csv' => ['nullable'],
];
}
/**
* Handle a passed validation attempt.
*/
protected function passedValidation(): void
{
$this->merge([
'number' => Str::random(30),
'status' => OrderStatus::default(),
'user_id' => auth()->id(),
'notes' => $this->notes ?: null,
'province_id' => $this->province_id ?: null,
'shipping_price' => OrderShipping::priceFor($this->shipping_method),
'delivery_time' => $this->delivery_time ?: OrderShipping::MORNING,
'delivery_at' => $this->delivery_at ?: date('Y-m-d'),
'source_app' => $this->source ?: OS::MOBILE_APP,
]);
}
/**
* Get the error messages for the defined validation rules.
*
* @return array<string, string>
*/
public function messages(): array
{
return [
'shipping_method.in' => sprintf('Valid sources: %s', implode(', ', array_keys(
OrderShipping::values()
))),
'payment_type_id.in' => sprintf('Valid sources: %s', implode(', ', array_keys(
OrderPayment::values()
))),
'delivery_time.in' => sprintf('Valid sources: %s', implode(', ', array_keys(
OrderShipping::times()
))),
'region.in' => sprintf('Valid sources: %s', implode(', ', array_keys(
Region::values()
))),
];
}
}