Skip to content

Commit

Permalink
Fix migrations after applying Laravel passport
Browse files Browse the repository at this point in the history
- Use `api` gurad by default for Role/Permission models
- Correct class
  • Loading branch information
tuandm committed Mar 11, 2020
1 parent ab65927 commit 299813c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions app/Laravue/Models/Permission.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
class Permission extends \Spatie\Permission\Models\Permission
{
public $guard_name = 'api';

/**
* To exclude permission management from the list
*
Expand Down
2 changes: 2 additions & 0 deletions app/Laravue/Models/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
*/
class Role extends \Spatie\Permission\Models\Role
{
public $guard_name = 'api';

/**
* Check whether current role is admin
* @return bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ class SetupRolePermissions extends Migration
public function up()
{
foreach (Acl::roles() as $role) {
Role::findOrCreate($role, 'api');
Role::findOrCreate($role);
}

$adminRole = Role::findByName(Acl::ROLE_ADMIN);
$managerRole = Role::findByName(Acl::ROLE_MANAGER);
$editorRole = Role::findByName(Acl::ROLE_EDITOR);
Expand Down
2 changes: 1 addition & 1 deletion database/seeds/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use App\Laravue\Models\User;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;
use Spatie\Permission\Models\Role;
use App\Laravue\Models\Role;

class DatabaseSeeder extends Seeder
{
Expand Down

0 comments on commit 299813c

Please sign in to comment.