@if (auth()->user()->can('show User'))
if(!$user->hasRole('jefe-cuentas-cobrar')){
}
When using a many-to-many relation in Laravel, you should use the attach() function to link models. So in this case, you can do the following: App\user::find(14)->skill()->attach(1);
https://laracasts.com/series/laravel-5-fundamentals/episodes/21
$this->middleware('permission:create', ['only' => ['create', 'store']]);
$this->middleware('permission:edit', ['only' => ['edit', 'update']]);
$this->middleware('permission:delete', ['only' => ['show', 'delete']]);
$accounts = Account::where('status', 1)->select('name', 'id')->get();
$accounts = $accounts->toArray();
$accounts = Account::where('status', 1)->select('name', 'id')->get();
http://masi.ctmtoursperu.com/api-docs#!/airlines
public function __construct()
{
// Si no has seteado la restriccion en el web.php, entonces se usa esto
// $this->middleware('permission:form-corporate');
}
Redirect to
return redirect()->route('result-sent-email', ['data' => http_build_query($res)]);
Permissions in blade template
@if(auth()->user()->can('Registrar Cobranzas Vacaciones'))
<!-- code here -->
@endif
Permissions in route web.php
Route::get('corporativo/cobranzas',
[
'as' => 'corporativo.cobranzas',
'uses' =>'CorporateController@form',
'middleware' => [
'permission:Registrar Cobranzas Corporativo',
]
]);
Route::post('corporativo/cobranzas/search',
[
'as' => 'corporativo.cobranzas.search',
'uses' => 'CorporateController@search',
'middleware' => [
'permission:Registrar Cobranzas Corporativo',
]
]);
Route::get('corporativo/detalle-de-compras/{parameters}',
[
'as'=>'corporativo.detalle.compras',
'uses'=>'CorporateController@buydetail',
// deberia tener estos 2 permisos
'middleware' => [
'permission:Registrar Cobranzas Corporativo',
'permission:Registrar Cobranzas Vacaciones',
]
]
);
Sources
https://laravel.com/docs/5.5/eloquent-relationships#updating-many-to-many-relationships https://appdividend.com/2018/05/17/laravel-many-to-many-relationship-example/ https://laravel.com/docs/5.5/migrations https://stackoverflow.com/questions/10290849/how-to-remove-multiple-utf-8-bom-sequences https://stackoverflow.com/questions/34800053/how-to-retrieve-data-with-zeros-in-eloquent tabla user has user https://stackoverflow.com/questions/5207160/what-is-a-csrf-token-what-is-its-importance-and-how-does-it-work/33829607#33829607 https://stackoverflow.com/questions/30916838/fit-inline-elements-in-a-row-with-bootstrap