2017-02-13 12:08:16 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App;
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
class Group extends Model
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The attributes that are mass assignable.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $fillable = [
|
|
|
|
'name'
|
|
|
|
];
|
2017-02-15 09:14:52 +00:00
|
|
|
|
2017-04-15 09:41:15 +01:00
|
|
|
public function adminPermissions()
|
|
|
|
{
|
|
|
|
return $this->belongsToMany(Permission::class, 'admin_group_permissions');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function hasAdminPermission(Group $group, Permission $permission)
|
|
|
|
{
|
|
|
|
return $this->adminPermissions()->where([
|
|
|
|
'permission_id' => $permission->id
|
|
|
|
])->count() > 0;
|
|
|
|
}
|
|
|
|
|
2017-02-15 09:14:52 +00:00
|
|
|
public function users()
|
|
|
|
{
|
|
|
|
return $this->belongsToMany(User::class, 'user_groups');
|
|
|
|
}
|
2017-02-13 12:08:16 +00:00
|
|
|
}
|