ldc-supportweb/app/Http/Requests/UpdateMessage.php

36 lines
744 B
PHP
Raw Normal View History

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