1. Go to this page and download the library: Download yurenery/security-request library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
yurenery / security-request example snippets
$this->action; //Массив дейсвия.
$this->actionName; //Имя действия. Находится в ключе.
class CategoryRequest extends FormRequest
{
use SecurityRequest;
/**
* Actions.
*
* @var array
*/
protected $actions = [
'view' => [
'methods' => [ 'GET' ],
'permission' => 'default',
],
'add' => [
'methods' => [ 'POST' ],
'permission' => 'default',
],
'edit' => [
'methods' => [ 'PUT', 'PATCH' ],
'permission' => 'default',
],
'delete' => [
'methods' => [ 'DELETE' ],
'permission' => 'default',
]
];
/**
* Rules array.
*
* @return array
*/
public function rulesArray()
{
$rules = [
'uri' => 'in', 'Name must be at least :min characters in length.', [ ':min' => 3 ]),
'name_*.max' => trans_db(app('translations'), 'validation-categories-name-max', 'Name must be maximum :max characters in length.', [ ':max' => 255 ]),
];
}
/**
* @return array
*/
protected function postActionMessages()
{
return $this->messagesArray();
}
/**
* Get action rules
*
* @return array
*/
protected function getAction()
{
return [ ];
}
/**
* Post action rules
*
* @return array
*/
protected function postAction()
{
return $this->rulesArray();
}
/**
* Put action rules
*
* @return array
*/
protected function putAction()
{
$rules = $this->rulesArray();
$category_id = $this->route('category');
$rules['uri'] = [ '