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

36 lines
740 B
PHP
Raw Permalink 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.
*
* @return bool
*/
public function authorize()
{
/** @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()
{
/** @var \App\Models\User */
$user = auth()->user();
return [
'message' => 'required|min:' . ($user->isAdmin() ? '5' : '20'),
];
}
}