Added the support for generating docs from template doc

This commit is contained in:
Simon Pocrnjič
2025-10-06 21:46:28 +02:00
parent 0c8d1e0b5d
commit cec5796acf
69 changed files with 4570 additions and 374 deletions
+33
View File
@@ -16,6 +16,7 @@ class User extends Authenticatable
/** @use HasFactory<\Database\Factories\UserFactory> */
use HasFactory;
use HasProfilePhoto;
use Notifiable;
use TwoFactorAuthenticatable;
@@ -64,4 +65,36 @@ protected function casts(): array
'password' => 'hashed',
];
}
/**
* Roles relationship.
*/
public function roles()
{
return $this->belongsToMany(Role::class)
->withTimestamps()
->select('roles.id', 'roles.name', 'roles.slug');
}
/**
* Retrieve a flattened collection of permissions via roles.
*/
public function permissions()
{
return $this->roles()->with('permissions')->get()->pluck('permissions')->flatten()->unique('id');
}
public function hasRole(string|array $roles): bool
{
$roles = (array) $roles;
return $this->roles->pluck('slug')->intersect($roles)->isNotEmpty();
}
public function hasPermission(string|array $permissions): bool
{
$permissions = (array) $permissions;
return $this->permissions()->pluck('slug')->intersect($permissions)->isNotEmpty();
}
}