45 lines
1.2 KiB
PHP
45 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Admin\Master;
|
|
|
|
use App\Traits\NotificationTrait;
|
|
use Illuminate\Contracts\Validation\Validator;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
class BarbershopRequest extends FormRequest
|
|
{
|
|
use NotificationTrait;
|
|
|
|
public function authorize(): bool
|
|
{
|
|
return Auth::check();
|
|
}
|
|
|
|
protected function prepareForValidation(): void
|
|
{
|
|
$this->merge([
|
|
'cash' => removeRupiahFormatting($this->cash),
|
|
]);
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'name' => ['required', 'string', 'max:50'],
|
|
'contact_number' => ['required', 'string', 'regex:/^\+?\d{10,15}$/'],
|
|
'landmark' => ['required', 'string', 'max:30'],
|
|
'address' => ['required', 'string', 'max:500'],
|
|
'opened' => ['required', 'date'],
|
|
'closed' => ['nullable', 'date'],
|
|
'cash' => ['required', 'numeric', 'min:0', 'max:99999999.99'],
|
|
'image' => ['required', 'image', 'mimes:jpeg,png,jpg,gif,svg', 'max:2048'],
|
|
];
|
|
}
|
|
|
|
protected function failedValidation(Validator $validator): void
|
|
{
|
|
$this->handleValidationFailure($validator);
|
|
}
|
|
}
|