Files
wticreatorstudio/Modules/Chat/Http/Requests/CreateRoleRequest.php
T
2024-02-12 22:54:20 -05:00

48 lines
943 B
PHP

<?php
namespace Modules\Chat\Http\Requests;
use Modules\Chat\Entities\Role;
use function GuzzleHttp\Psr7\str;
use Illuminate\Foundation\Http\FormRequest;
class CreateRoleRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
protected function prepareForValidation()
{
$this->sanitize();
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
$rules = Role::$rules;
$rules['name'] = 'required|string|max:100|unique:roles';
return $rules;
}
public function sanitize()
{
$input = $this->all();
$input['name'] = htmlspecialchars($input['name']);
$this->replace($input);
}
}