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
58
plugins-core/documents/src/Models/Document.php
Normal file
58
plugins-core/documents/src/Models/Document.php
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
namespace Inhaus\Plugins\Documents\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
#[Fillable(['folder_id', 'title', 'description', 'created_by', 'updated_by'])]
|
||||
class Document extends Model
|
||||
{
|
||||
protected static function booted(): void
|
||||
{
|
||||
// Dateien aller Fassungen mit entfernen.
|
||||
static::deleting(fn (Document $document) => $document->versions()->get()->each->delete());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo<DocumentFolder, $this>
|
||||
*/
|
||||
public function folder(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(DocumentFolder::class, 'folder_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo<DocumentVersion, $this>
|
||||
*/
|
||||
public function currentVersion(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(DocumentVersion::class, 'current_version_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany<DocumentVersion, $this>
|
||||
*/
|
||||
public function versions(): HasMany
|
||||
{
|
||||
return $this->hasMany(DocumentVersion::class)->orderByDesc('version');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo<User, $this>
|
||||
*/
|
||||
public function updater(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'updated_by');
|
||||
}
|
||||
|
||||
public function downloadUrl(?DocumentVersion $version = null): string
|
||||
{
|
||||
$version ??= $this->currentVersion;
|
||||
|
||||
return route('documents.download', ['document' => $this->id, 'version' => $version?->version, 'name' => $version?->name ?? 'datei']);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue