47 lines
1.1 KiB
PHP
47 lines
1.1 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 文件功能:修改聊天室设置请求验证器
|
||
|
|
*
|
||
|
|
* @author ChatRoom Laravel
|
||
|
|
*
|
||
|
|
* @version 1.0.0
|
||
|
|
*/
|
||
|
|
|
||
|
|
namespace App\Http\Requests;
|
||
|
|
|
||
|
|
use Illuminate\Foundation\Http\FormRequest;
|
||
|
|
|
||
|
|
class UpdateRoomRequest extends FormRequest
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* Determine if the user is authorized to make this request.
|
||
|
|
*/
|
||
|
|
public function authorize(): bool
|
||
|
|
{
|
||
|
|
// 权限判断(是否为房主)会直接在 Controller/Policy 中进行
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Get the validation rules that apply to the request.
|
||
|
|
*
|
||
|
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||
|
|
*/
|
||
|
|
public function rules(): array
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
'name' => ['required', 'string', 'max:50', 'unique:rooms,name,'.$this->route('id')],
|
||
|
|
'description' => ['nullable', 'string', 'max:255'],
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
public function messages(): array
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
'name.required' => '房间名称不能为空。',
|
||
|
|
'name.unique' => '该房间名称已存在。',
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}
|