33 lines
766 B
PHP
Executable File
33 lines
766 B
PHP
Executable File
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class UpdateMarkerRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return $this->user()->can('update', $this->route('marker'));
|
|
}
|
|
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'name' => [
|
|
'required',
|
|
'string',
|
|
'max:50',
|
|
Rule::unique('markers', 'name')
|
|
->where('user_id', $this->user()->id)
|
|
->ignore($this->route('marker')),
|
|
],
|
|
'color' => ['required', 'string', 'regex:/^#[0-9a-fA-F]{6}$/'],
|
|
];
|
|
}
|
|
}
|