Skip to content

Commit

Permalink
Merge pull request #1548 from spatie/gettable
Browse files Browse the repository at this point in the history
Declare table relations earlier to improve guarded/fillable detection accuracy
  • Loading branch information
drbyte authored Aug 15, 2020
2 parents 20b9781 + bce7d9b commit 5c1cc46
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/Models/Permission.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ public function __construct(array $attributes = [])
$attributes['guard_name'] = $attributes['guard_name'] ?? config('auth.defaults.guard');

parent::__construct($attributes);
}

$this->setTable(config('permission.table_names.permissions'));
public function getTable()
{
return config('permission.table_names.permissions', parent::getTable());
}

public static function create(array $attributes = [])
Expand Down
5 changes: 4 additions & 1 deletion src/Models/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ public function __construct(array $attributes = [])
$attributes['guard_name'] = $attributes['guard_name'] ?? config('auth.defaults.guard');

parent::__construct($attributes);
}

$this->setTable(config('permission.table_names.roles'));
public function getTable()
{
return config('permission.table_names.roles', parent::getTable());
}

public static function create(array $attributes = [])
Expand Down

0 comments on commit 5c1cc46

Please sign in to comment.