<?php
namespace AppModels;
use IlluminateDatabaseEloquentModel;
class Role extends Model
{
/**
* The users that belong to the role.
*/
public function users()
{
return $this->belongsToMany(User::class)->using(RoleUser::class);
}
}
/**
*When defining the RoleUser model, you should extend the
IlluminateDatabaseEloquentRelationsPivot
*/
<?php
namespace AppModels;
use IlluminateDatabaseEloquentRelationsPivot;
class RoleUser extends Pivot
{
//
}