ldc-supportweb/app/Http/Requests/Bo/UpdateMessage.php
2023-08-14 09:23:39 +00:00

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'),
];
}
}