wip
This commit is contained in:
@@ -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'],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user