How i do that when which type of users login its stay its own dashboard/profile. User and SuperAdmin is okay,but when i login with branchAdmin account and write other users url in browser it go on its dashboard it not stay in its own account.
Routes:
Route::group(['middleware' => [ 'auth', 'isAdmin']], function(){
Route::get('/profile','ProfileController@getIndex');
});
Route::group(['middleware' => [ 'auth', 'isBranchAdmin']], function(){
Route::get('/branch','BranchController@gettIndex');
});
Route::group(['middleware' => [ 'auth', 'isNotAdmin']], function(){
Route::get('/Super/admin', 'AdminController@getIndex');
});
View:
<div class="col-xs-12 col-sm-12 col-md-3 col-lg-3">
@if(Auth::check() && Auth::user()->type === 'User')
<ul class="nav nav-pills nav-stacked">
<li role="presentation" class="active">
<a id="bootstrap-overrides" href="/home">
Home
</a>
</li>
<li role="presentation">
<a id="bootstrap-overrides" href="/contact">
Contact
</a>
</li>
<li role="presentation">
<a id="bootstrap-overrides" href="/about">
About
</a>
</li>
<li role="presentation">
<a id="bootstrap-overrides" href="/blog">
Blog
</a>
</li>
<li role="presentation">
<a id="bootstrap-overrides" href="/faqs">
FAQs
</a>
</li>
</ul>
@elseif(Auth::check() && Auth::user()->type === 'Admin')
<ul class="nav nav-pills nav-stacked">
<li role="presentation" @if(Request::path() === 'companies') class="active" @endif>
<a href="/companies">
Companies
</a>
</li>
<li role="presentation" @if(Request::path() === 'branchies') class="active" @endif>
<a href="/branchies">
Branchies
</a>
</li>
</ul>
Middlewares:
UserIsAdmin:
class UserIsAdmin
{
public function handle($request, Closure $next)
{
if(Auth::user()->type === 'Admin'){
return redirect('/Super/admin');
}
return $next($request);
}
}
UserIsNotAdmin:
class UserIsNotAdmin
{
public function handle($request, Closure $next)
{
if(Auth::user()->type === 'User'){
return redirect('/profile');
}
return $next($request);
}
}
BranchAdmin:
class BranchAdmin
{ note-> (" This middleware is not working ")
public function handle($request, Closure $next){
if(Auth::user()->type === 'BranchAdmin'){
return redirect('/branch');
}
return $next($request);
}
}
via Haider