Different Dashboard for Each User Type
I'm looking to create a different version of the dashboard for each user type that displays different information based on access. I tried creating an if statement within the current dashboard route but get a server error.
Any recommendations on how to implement this?
Route::group(['middleware' => 'wave'], function () {
if(Auth::user()->role == 'premium'){
Route::get('dashboard', '\Wave\Http\Controllers\DashboardController@index')->name('wave.dashboard');
}
else{
}
});
Hi there,
I would personally move the logic away from the routes file to a controller where you could add the different checks and return the necessary content to the user based on their role.
Or if you are using Livewire, you could create different dashboard components and inside your blade view component itself show the required component, eg:
@if(auth()->user()->role == 'premium')
@livewire('premium')
@elseif(auth()->user()->role == 'pro')
@livewire('pro')
@else
@livewire('free')
@endif
Let me know how it goes!