*/ use HasFactory, InteractsWithMedia, LogsActivity, SoftDeletes; /** * The attributes that are mass assignable. * * @var list */ 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 */ 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 */ public function workspace(): BelongsTo { return $this->belongsTo(Workspace::class); } /** * Get the client that owns the folder. * * @return BelongsTo */ public function client(): BelongsTo { return $this->belongsTo(Client::class); } /** * Get the user who created the folder. * * @return BelongsTo */ public function creator(): BelongsTo { return $this->belongsTo(User::class, 'created_by'); } /** * Get the user assigned to the folder. * * @return BelongsTo */ public function assignee(): BelongsTo { return $this->belongsTo(User::class, 'assigned_to'); } /** * Get the messages for the folder. * * @return HasMany */ public function messages(): HasMany { return $this->hasMany(Message::class); } /** * Get the invitations for the folder. * * @return HasMany */ public function invitations(): HasMany { return $this->hasMany(FolderInvitation::class); } public function getActivitylogOptions(): LogOptions { return LogOptions::defaults() ->logFillable() ->logOnlyDirty() ->dontSubmitEmptyLogs(); } }