PLATFORM
  • Tails

    Create websites with TailwindCSS

  • Blocks

    Design blocks for your website

  • Wave

    Start building the next great SAAS

  • Pines

    Alpine & Tailwind UI Library

  • Auth

    Plug'n Play Authentication for Laravel

  • Designer comingsoon

    Create website designs with AI

  • DevBlog comingsoon

    Blog platform for developers

  • Static

    Build a simple static website

  • SaaS Adventure

    21-day program to build a SAAS

Question By
Unsolved

Different Dashboard for Each User Type

meaghanpsavage

Feb 6th, 2023 04:31 PM

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{

	}
});
bobbyiliev

Feb 7th, 2023 01:12 AM

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!