Users module: accounts, groups, permissions with needs, manager:create-user

This commit is contained in:
Matthijs Iriks committed 2026-12-04 01:25:29 +01:00
1 parent 08289db744
commit f86f5aea28
25 files changed
+744 -58

No files matched your search

+25
View File
@@ -2,10 +2,35 @@
namespace IriksIT\Manager\Models;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use IriksIT\Manager\Support\ModuleRegistry;
/**
* A set of permissions with a name ("Writers"). Accounts are put in groups; a group is the
* only place where permissions are set.
*
* @property list<string>|null $permissions
*/
class Group extends Model
{
protected function casts(): array
{
return ['permissions' => 'array'];
}
public function users(): BelongsToMany
{
return $this->belongsToMany(config('manager.user_model'), config('manager.table_prefix').'group_user', 'group_id', 'user_id');
}
/**
* What the group allows, without anything that is no permission (any more), for instance
* of a module that was switched off.
*
* @return list<string>
*/
public function allowed(): array
{
return app(ModuleRegistry::class)->complete($this->permissions ?? []);
}
}