feat: L'Ami Fiduciaire V1.0.0 — full codebase with Story 0.1 complete
Initial commit of the L'Ami Fiduciaire SaaS platform built on Laravel 12, Vue 3, Inertia.js 2, and Tailwind CSS 4. Story 0.1 (rename folders to declarations in database) is implemented and code-reviewed: migration, rollback, and 6 Pest tests all passing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
149
app/Models/Folder.php
Normal file
149
app/Models/Folder.php
Normal file
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\FolderPriority;
|
||||
use App\Enums\FolderStatus;
|
||||
use App\Enums\FolderType;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||
|
||||
class Folder extends Model implements HasMedia
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\FolderFactory> */
|
||||
use HasFactory, InteractsWithMedia, LogsActivity, SoftDeletes;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'workspace_id',
|
||||
'client_id',
|
||||
'created_by',
|
||||
'title',
|
||||
'type',
|
||||
'period_year',
|
||||
'period_month',
|
||||
'period_quarter',
|
||||
'due_date',
|
||||
'status',
|
||||
'priority',
|
||||
'assigned_to',
|
||||
'validated_at',
|
||||
'closed_at',
|
||||
'confirmation_requested_at',
|
||||
'confirmation_media_id',
|
||||
'confirmed_by_type',
|
||||
'confirmed_by_id',
|
||||
'confirmation_signature',
|
||||
'refused_at',
|
||||
'refusal_reason',
|
||||
'notes_internal',
|
||||
'notes_client',
|
||||
'created_at',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'type' => FolderType::class,
|
||||
'status' => FolderStatus::class,
|
||||
'priority' => FolderPriority::class,
|
||||
'validated_at' => 'datetime',
|
||||
'closed_at' => 'datetime',
|
||||
'confirmation_requested_at' => 'datetime',
|
||||
'refused_at' => 'datetime',
|
||||
'due_date' => 'date',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Register media collections.
|
||||
*/
|
||||
public function registerMediaCollections(): void
|
||||
{
|
||||
$this->addMediaCollection('documents')->useDisk('local');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the workspace that owns the folder.
|
||||
*
|
||||
* @return BelongsTo<Workspace, $this>
|
||||
*/
|
||||
public function workspace(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Workspace::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the client that owns the folder.
|
||||
*
|
||||
* @return BelongsTo<Client, $this>
|
||||
*/
|
||||
public function client(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Client::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user who created the folder.
|
||||
*
|
||||
* @return BelongsTo<User, $this>
|
||||
*/
|
||||
public function creator(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'created_by');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user assigned to the folder.
|
||||
*
|
||||
* @return BelongsTo<User, $this>
|
||||
*/
|
||||
public function assignee(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'assigned_to');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the messages for the folder.
|
||||
*
|
||||
* @return HasMany<Message>
|
||||
*/
|
||||
public function messages(): HasMany
|
||||
{
|
||||
return $this->hasMany(Message::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the invitations for the folder.
|
||||
*
|
||||
* @return HasMany<FolderInvitation>
|
||||
*/
|
||||
public function invitations(): HasMany
|
||||
{
|
||||
return $this->hasMany(FolderInvitation::class);
|
||||
}
|
||||
|
||||
public function getActivitylogOptions(): LogOptions
|
||||
{
|
||||
return LogOptions::defaults()
|
||||
->logFillable()
|
||||
->logOnlyDirty()
|
||||
->dontSubmitEmptyLogs();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user