-
Notifications
You must be signed in to change notification settings - Fork 0
Traits
Eugene Min edited this page Feb 27, 2016
·
12 revisions
Automatically redirects you after CRUD operations in resource controllers, shows flash message with CRUD status.
You can pass string or array with CREATE, UPDATE, DELETE sequence:
use \Milax\Mconsole\Traits\Redirectable;
public function __construct()
{
$this->setRedirects('/mconsole/users');
$this->setRedirects(['/mconsole/permissions', '/mconsole/users', '/mconsole/users']);
}Alternatively you can set protected $redirectTo as string or array with create, update, delete urls:
protected $redirectTo = [
'/mconsole/permissions',
'/mconsole/users',
'/mconsole/users',
];Automatically creates pagination for given model with defined table headers.
use \Milax\Mconsole\Traits\Paginatable;
protected $model = 'App\User';
protected $perPage = 20;Alternatively you can set per page number by using $this->setPerPage(20).
$this->setPerPage(20);Automatically creates filter form for queries. You can set rules by using these methods in your controller:
use Milax\Mconsole\Traits\Filterable;
protected $model = 'App\User';
public function __construct()
{
$this->setText('Email', 'email', true)
->setSelect('Role', 'role_id', MconsoleRole::all()->lists('name', 'id'), true);
}Alternatively you can set filters by assigning protected $filters property array:
protected $filters = [
[
'label' => 'Email',
'key' => 'email',
'exact' => true,
],
[
'label' => 'Role',
'key' => 'role_id',
'exact' => true,
'options' => [
[1 => 'Some role'],
[2 => 'Another role'],
]
],
];If you using one Paginatable, Filterable or both traits you are required to use this trait.