35 lines
747 B
PHP
35 lines
747 B
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Bo;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class UpdateMessage extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*
|
|
* @return boolean
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
/** @var \App\Models\User|null $user */
|
|
$user = auth()->user();
|
|
|
|
return auth()->check() && $user->isAdmin();
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
/** @var \App\Models\User */
|
|
$user = auth()->user();
|
|
return [
|
|
'message' => 'required|min:' . ($user->isAdmin() ? '5' : '20'),
|
|
];
|
|
}
|
|
}
|