Manage clients, testimonials and talks through the API
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
47
app/Http/Requests/Api/V1/ClientRequest.php
Normal file
47
app/Http/Requests/Api/V1/ClientRequest.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Requests\Api\V1;
|
||||
|
||||
use App\Models\Client;
|
||||
use App\Rules\Translatable;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
/**
|
||||
* The panel's client form, as rules.
|
||||
*/
|
||||
class ClientRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$client = $this->route('client');
|
||||
$creating = ! $client instanceof Client;
|
||||
$sometimes = $creating ? 'required' : 'sometimes';
|
||||
|
||||
return [
|
||||
'name' => [$sometimes, 'string', 'max:255'],
|
||||
'slug' => [
|
||||
$sometimes,
|
||||
'string',
|
||||
'max:255',
|
||||
'alpha_dash:ascii',
|
||||
Rule::unique('clients', 'slug')->ignore($client?->id),
|
||||
],
|
||||
'sector' => ['sometimes', 'nullable', new Translatable(max: 120)],
|
||||
'logo' => ['sometimes', 'nullable', 'string', 'max:2048'],
|
||||
'url' => ['sometimes', 'nullable', 'url', 'max:2048'],
|
||||
'is_public' => ['sometimes', 'boolean'],
|
||||
'position' => ['sometimes', 'integer', 'min:0'],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user