- (Phase 8) 后台各维度管理与配置 - (Phase 9) 全自动静默挂机修仙升级 - (Phase 9) 四大维度风云排行榜页面 - (Phase 10) 全站留言板与悄悄话私信功能 - 运行 Pint 代码格式化
40 lines
1022 B
PHP
40 lines
1022 B
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class StoreGuestbookRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return \Illuminate\Support\Facades\Auth::check(); // 必须登录
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'towho' => 'nullable|string|max:50',
|
|
'secret' => 'sometimes|boolean',
|
|
'text_title' => 'nullable|string|max:250',
|
|
'text_body' => 'required|string|max:2000',
|
|
];
|
|
}
|
|
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'text_body.required' => '留言内容不能为空!',
|
|
'text_body.max' => '留言内容不能超过 2000 个字符。',
|
|
];
|
|
}
|
|
}
|