Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type to Eloquent Relations #585

Merged
merged 1 commit into from
Feb 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Database/Concerns/HasAbilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
use Silber\Bouncer\Conductors\RemovesAbilities;
use Silber\Bouncer\Conductors\UnforbidsAbilities;

use Illuminate\Database\Eloquent\Relations\MorphToMany;

trait HasAbilities
{
/**
Expand All @@ -34,7 +36,7 @@ public static function bootHasAbilities()
*
* @return \Illuminate\Database\Eloquent\Relations\MorphToMany
*/
public function abilities()
public function abilities(): MorphToMany
{
$relation = $this->morphToMany(
Models::classname(Ability::class),
Expand Down
4 changes: 3 additions & 1 deletion src/Database/Concerns/HasRoles.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
use Silber\Bouncer\Conductors\RemovesRoles;
use Silber\Bouncer\Database\Queries\Roles as RolesQuery;

use Illuminate\Database\Eloquent\Relations\MorphToMany;

trait HasRoles
{
/**
Expand All @@ -33,7 +35,7 @@ public static function bootHasRoles()
*
* @return \Illuminate\Database\Eloquent\Relations\MorphToMany
*/
public function roles()
public function roles(): MorphToMany
{
$relation = $this->morphToMany(
Models::classname(Role::class),
Expand Down
6 changes: 4 additions & 2 deletions src/Database/Concerns/IsAbility.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
use Silber\Bouncer\Database\Scope\TenantScope;
use Silber\Bouncer\Database\Queries\AbilitiesForModel;

use Illuminate\Database\Eloquent\Relations\MorphToMany;

trait IsAbility
{
/**
Expand Down Expand Up @@ -147,7 +149,7 @@ public static function makeForModel($model, $attributes)
*
* @return \Illuminate\Database\Eloquent\Relations\MorphToMany
*/
public function roles()
public function roles(): MorphToMany
{
$relation = $this->morphedByMany(
Models::classname(Role::class),
Expand All @@ -163,7 +165,7 @@ public function roles()
*
* @return \Illuminate\Database\Eloquent\Relations\MorphToMany
*/
public function users()
public function users(): MorphToMany
{
$relation = $this->morphedByMany(
Models::classname(User::class),
Expand Down
5 changes: 3 additions & 2 deletions src/Database/Concerns/IsRole.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use InvalidArgumentException;
use Illuminate\Support\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphToMany;

trait IsRole
{
Expand Down Expand Up @@ -43,9 +44,9 @@ public static function bootIsRole()
/**
* The users relationship.
*
* @return \Illuminate\Database\Eloquent\Relations\MorphedByMany
* @return \Illuminate\Database\Eloquent\Relations\MorphedToMany
*/
public function users()
public function users(): MorphToMany
{
$relation = $this->morphedByMany(
Models::classname(User::class),
Expand Down