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,60 @@
<?php
namespace App\Http\Controllers\Api\V1\Carousel\Requests;
use App\Models\CMS\Media\Carousel;
use App\Models\System\Settings\OS;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class CarouselIndexRequest 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 [
'place' => ['nullable', 'string', Rule::in(array_keys(
Carousel::places()
))],
'perPage' => ['nullable', 'integer'],
'fields' => ['nullable', 'string'],
];
}
/**
* Handle a passed validation attempt.
*/
protected function passedValidation(): void
{
$fields = [];
if ($this->fields) {
$sanitezedFields = validateCommaSeperated($this->fields, Carousel::class);
$fields['fields'] = ! empty($sanitezedFields) ? $sanitezedFields : ['*'];
} else {
$fields['fields'] = ['*'];
}
$this->merge([
'perPage' => $this->perPage ?: 6,
...$fields,
]);
}
/**
* Get the error messages for the defined validation rules.
*
* @return array<string, string>
*/
public function messages(): array
{
return [
'place.in' => sprintf('Valid sources: %s', implode(', ', array_keys(OS::apps()))),
'app.in' => sprintf('Valid sources: %s', implode(', ', array_keys(OS::apps()))),
];
}
}