38 lines
1.0 KiB
PHP
38 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Admin\System;
|
|
|
|
use App\Models\GeneralSetting;
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class GeneralSettingRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array<string, ValidationRule|array<mixed>|string>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
$settingExists = GeneralSetting::exists();
|
|
|
|
return [
|
|
'name' => ['required', 'string', 'max:50'],
|
|
'description' => ['required', 'string'],
|
|
'address' => ['required', 'string'],
|
|
'phone' => ['required', 'string', 'max:20'],
|
|
'logo' => [$settingExists ? 'nullable' : 'required', 'image', 'max:2048'],
|
|
'icon' => [$settingExists ? 'nullable' : 'required', 'image', 'max:1024'],
|
|
];
|
|
}
|
|
}
|