Using Laravel Voyager with Laravel Spark

There is an easy way to implement the Voyager User class into the Spark User class. The Spark installer will set up your App\User.php file to extend from Laravel\Spark\User. You will be able to log into the admin panel but the Voyager routes will not work.

In order to implement the Voyager User class you need to use Voyager\Contracts\User and Voyager\Traits\VoyagerUser. You can find this set up in the Voyager src directory, inside of Models.

<?php

namespace TCG\Voyager\Models;

use Carbon\Carbon;
use Illuminate\Foundation\Auth\User as Authenticatable;
use TCG\Voyager\Contracts\User as UserContract;
use TCG\Voyager\Traits\VoyagerUser;

class User extends Authenticatable implements UserContract
{
    use VoyagerUser;

    protected $guarded = [];
    
    // the rest has been ommitted

}

We can see our App\User class does not have these directives.

<?php

namespace App;

use Laravel\Spark\User as SparkUser;

class User extends SparkUser
{
    // contents ommitted
}

So all we have to do is a little copy and paste like so:

<?php


namespace App;

use Laravel\Spark\User as SparkUser;

use TCG\Voyager\Contracts\User as UserContract;
use TCG\Voyager\Traits\VoyagerUser;

class User extends SparkUser implements UserContract
{

    use VoyagerUser;

    // contents ommitted   

}

After that you should be able to access your Voyager routes as well as your Spark routes.