Phase 6 (Teil 1): Dokumente und Organigramm
- Dokumente-Plugin: Ordnerbaum mit vererbten Rechten und Sichtbarkeit, Hochladen per Ziehen und Ablegen, Versionen, Suche, Pagebuilder-Block - Organigramm aus den Vorgesetzten, Vorgesetzte im Admin pflegbar - Personensuche im Kopf übernimmt nur noch Suchbegriffe des Verzeichnisses Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
21c706e5f5
commit
d6d5d4b0fe
110 changed files with 2209 additions and 208 deletions
51
plugins-core/documents/src/Models/DocumentFolder.php
Normal file
51
plugins-core/documents/src/Models/DocumentFolder.php
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
namespace Inhaus\Plugins\Documents\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Inhaus\Plugins\Documents\FolderTree;
|
||||
|
||||
#[Fillable(['parent_id', 'name', 'description', 'sort', 'created_by'])]
|
||||
class DocumentFolder extends Model
|
||||
{
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::saved(fn (DocumentFolder $folder) => FolderTree::flush($folder->wasRecentlyCreated || $folder->wasChanged('parent_id')));
|
||||
static::deleted(fn () => FolderTree::flush(true));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{0: string, 1: int}
|
||||
*/
|
||||
public function permissionResource(): array
|
||||
{
|
||||
return ['document_folder', $this->id];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo<DocumentFolder, $this>
|
||||
*/
|
||||
public function parent(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(DocumentFolder::class, 'parent_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany<DocumentFolder, $this>
|
||||
*/
|
||||
public function children(): HasMany
|
||||
{
|
||||
return $this->hasMany(DocumentFolder::class, 'parent_id')->orderBy('sort')->orderBy('name');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany<Document, $this>
|
||||
*/
|
||||
public function documents(): HasMany
|
||||
{
|
||||
return $this->hasMany(Document::class, 'folder_id');
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue