This commit is contained in:
2025-09-25 03:03:31 +05:00
commit ae480cf2f6
2768 changed files with 1485826 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
<?php
namespace App\Http\Controllers\Api\V1\Channel\Requests;
use App\Models\Ecommerce\Channel\Channel;
use Illuminate\Foundation\Http\FormRequest;
class ChannelIndexRequest 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 [
'perPage' => ['nullable', 'integer'],
'fields' => ['nullable', 'string'],
];
}
/**
* Handle a passed validation attempt.
*/
protected function passedValidation(): void
{
$fields = [];
if ($this->fields) {
$sanitezedFields = validateCommaSeperated($this->fields, Channel::class);
$fields['fields'] = ! empty($sanitezedFields) ? $sanitezedFields : ['*'];
} else {
$fields['fields'] = ['*'];
}
$this->merge([
'perPage' => $this->perPage ?: 6,
...$fields,
]);
}
}