wip
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
<?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 [
|
||||
'version' => ['required', 'string', 'max:255'],
|
||||
'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()))),
|
||||
];
|
||||
}
|
||||
}
|
||||
20
app/Http/Requests/Api/V1/Auth/AuthLoginRequest.php
Normal file
20
app/Http/Requests/Api/V1/Auth/AuthLoginRequest.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Api\V1\Auth;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
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 [
|
||||
'phone_number' => ['required', 'integer', 'between:61000000,71999999'],
|
||||
];
|
||||
}
|
||||
}
|
||||
41
app/Http/Requests/Api/V1/Auth/AuthVerifyRequest.php
Normal file
41
app/Http/Requests/Api/V1/Auth/AuthVerifyRequest.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?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 [
|
||||
'phone_number' => ['required', 'integer', 'between:61000000,65999999'],
|
||||
'code' => ['required', 'integer', new VerificationRule($this->phone_number)],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Body Parameters for scribe
|
||||
*
|
||||
* @return array<string, array<string, string>>
|
||||
*/
|
||||
public function bodyParameters(): array
|
||||
{
|
||||
return [
|
||||
'phone_number' => [
|
||||
'description' => 'Phone number to verify',
|
||||
'example' => '61929248',
|
||||
],
|
||||
'code' => [
|
||||
'description' => 'Code to verify',
|
||||
'example' => '99934',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
22
app/Http/Requests/Api/V1/Brand/BrandIndexRequest.php
Normal file
22
app/Http/Requests/Api/V1/Brand/BrandIndexRequest.php
Normal 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())],
|
||||
];
|
||||
}
|
||||
}
|
||||
33
app/Http/Requests/Api/V1/Brand/BrandProductsRequest.php
Normal file
33
app/Http/Requests/Api/V1/Brand/BrandProductsRequest.php
Normal 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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
21
app/Http/Requests/Api/V1/Cart/CartAddProductRequest.php
Normal file
21
app/Http/Requests/Api/V1/Cart/CartAddProductRequest.php
Normal 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'],
|
||||
];
|
||||
}
|
||||
}
|
||||
20
app/Http/Requests/Api/V1/Cart/CartRemoveRequest.php
Normal file
20
app/Http/Requests/Api/V1/Cart/CartRemoveRequest.php
Normal 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'],
|
||||
];
|
||||
}
|
||||
}
|
||||
22
app/Http/Requests/Api/V1/Cart/CartStoreRequest.php
Normal file
22
app/Http/Requests/Api/V1/Cart/CartStoreRequest.php
Normal 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'],
|
||||
];
|
||||
}
|
||||
}
|
||||
21
app/Http/Requests/Api/V1/Category/CategoryIndexRequest.php
Normal file
21
app/Http/Requests/Api/V1/Category/CategoryIndexRequest.php
Normal 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'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
20
app/Http/Requests/Api/V1/Product/ProductCommentStore.php
Normal file
20
app/Http/Requests/Api/V1/Product/ProductCommentStore.php
Normal 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'],
|
||||
];
|
||||
}
|
||||
}
|
||||
33
app/Http/Requests/Api/V1/Product/ProductIndexRequest.php
Normal file
33
app/Http/Requests/Api/V1/Product/ProductIndexRequest.php
Normal 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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -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()))),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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'],
|
||||
];
|
||||
}
|
||||
}
|
||||
102
app/Http/Requests/CheckoutOrderRequest.php
Normal file
102
app/Http/Requests/CheckoutOrderRequest.php
Normal 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()
|
||||
))),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user