'boolean' ]; public function roles() { return $this->belongsToMany(Role::class)->withpivot('granted')->withTimestamps(); } public function users() { return $this->belongsToMany(User::class)->withPivot('granted')->withTimestamps(); } public function matches($permission) { if (!$this->is_wildcard) { return $this->name === $permission; } $pattern = str_replace('*', '.*', $this->name); return preg_match('/^' . $pattern . '$/', $permission); } }