46 lines
1 KiB
PHP
46 lines
1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Setting;
|
|
|
|
use App\Enums\SettingTypes;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class UpdateRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*
|
|
* @return bool
|
|
*/
|
|
public function authorize()
|
|
{
|
|
// TODO : Add role admin check
|
|
return auth()->check();
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function rules()
|
|
{
|
|
$setting = $this->route('setting');
|
|
|
|
switch ($setting->type->value) {
|
|
case SettingTypes::string()->value:
|
|
$validate = "required";
|
|
break;
|
|
case SettingTypes::numeric()->value:
|
|
$validate = "numeric|min:0|required";
|
|
break;
|
|
case SettingTypes::picture()->value:
|
|
$validate = "file|mimes:png|required";
|
|
break;
|
|
}
|
|
|
|
return [
|
|
'value' => $validate
|
|
];
|
|
}
|
|
}
|