41 lines
923 B
PHP
41 lines
923 B
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Admin\Menu;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Contracts\Validation\Validator;
|
|
use Illuminate\Http\Exceptions\HttpResponseException;
|
|
|
|
class UpdateRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*
|
|
* @return bool
|
|
*/
|
|
public function authorize()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function rules()
|
|
{
|
|
return [
|
|
'name' => 'required',
|
|
'parent_id' => 'required',
|
|
'sort' => 'required|numeric',
|
|
'type' => 'required|in:1,2',
|
|
];
|
|
}
|
|
|
|
protected function failedValidation(Validator $validator)
|
|
{
|
|
throw new HttpResponseException(response()->json(['code'=>1,'msg'=>$validator->errors()->first()]));
|
|
}
|
|
}
|