Created
December 29, 2019 10:43
-
-
Save localdisk/bbdf15ef6d3ce1928c305815df08f6e1 to your computer and use it in GitHub Desktop.
User Role sample.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Role extends Model | |
{ | |
public function users() | |
{ | |
// permissions まで含めると morphedByMany がよさそう | |
return $this->belongsToMany(User::class); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class User extends Authenticatable | |
{ | |
public function roles() | |
{ | |
return $this->belongsToMany(Role::class); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment