As the project name states, QuickAdminPanel is for building admin panels. But for a long time customers asked us to build at least some kind of front-end faced boilerplate. So this is our first step in that direction – now, when creating a new panel, you can choose Starter Template as “User Frontend”.

What does it do?

Without this template, default homepage of your app redirects to /login URL with sign in form.
This new template creates a default homepage – the same as default Laravel app:

On top of that, it installs “Registration” module by default, so front-end users may also register, and then they get to front-end dashboard:

Final thing – front-end users see menu item to Change Password:

How does it work in the code?

In the code, then you can create more front-end functionality.

Here’s how routes/web.php is separated:

Route::get('/', function () {
    return view('welcome');

// User routes
Route::group(['as' => 'client.', 'middleware' => ['auth']], function () {
    Route::get('home', 'HomeController@redirect');
    Route::get('dashboard', 'HomeController@index')->name('home');
    Route::get('change-password', 'ChangePasswordController@create')->name('password.create');
    Route::post('change-password', 'ChangePasswordController@update')->name('password.update');


// Admin routes
  'prefix' => 'admin', 
  'as' => 'admin.', 
  'namespace' => 'Admin', 
  'middleware' => ['auth.admin']
], function () {
    Route::get('/', 'HomeController@index')->name('home');

    // Permissions
    Route::delete('permissions/destroy', 'PermissionsController@massDestroy')->name('permissions.massDestroy');
    Route::resource('permissions', 'PermissionsController');

    // Roles
    Route::delete('roles/destroy', 'RolesController@massDestroy')->name('roles.massDestroy');
    Route::resource('roles', 'RolesController');

    // Users
    Route::delete('users/destroy', 'UsersController@massDestroy')->name('users.massDestroy');
    Route::resource('users', 'UsersController');

Also, you may notice a new middleware auth.admin which is defined in file app/Http/Middleware/CheckIfAdmin.php:

class CheckIfAdmin
    public function handle($request, Closure $next, $guard = null)
        if (Auth::guard($guard)->check() && auth()->user()->is_admin) {
            return $next($request);

        return redirect('/home');

In this code, system checks if the role of the user is Administrator – then they get access to adminpanel view, front-end users are registered to front-end view.

Final piece of code here is auth()->user()->is_admin property, which is not a field in the database table, but rather an attribute in the app/User.php model:

public function getIsAdminAttribute()
    return $this->roles()->where('id', 1)->exists();

You can read more about our Roles/Permissions system in this article, or watch this demo video.

Main point here is that registered users only see the front-end template view, and they don’t even see adminpanel at all, except for login/register form design, which still comes from adminpanel theme.

That’s it for now! Try it our for your new panels.
We have plans to expand that front-end view with more functionality, stay tuned for the news.