*/ use HasFactory, LogsActivity, SoftDeletes; /** * The attributes that are mass assignable. * * @var list */ protected $fillable = [ 'name', 'slug', ]; /** * Boot the model. */ protected static function boot(): void { parent::boot(); static::creating(function (Workspace $workspace) { if (empty($workspace->slug)) { $workspace->slug = Str::slug($workspace->name); } }); static::updating(function (Workspace $workspace) { if (empty($workspace->slug)) { $workspace->slug = Str::slug($workspace->name); } }); } /** * Get the clients for the workspace. * * @return HasMany */ public function clients(): HasMany { return $this->hasMany(Client::class); } /** * Get the declarations for the workspace. * * @return HasMany */ public function declarations(): HasMany { return $this->hasMany(Declaration::class); } /** * The users that belong to the workspace. * * @return BelongsToMany */ public function users(): BelongsToMany { return $this->belongsToMany(User::class, 'workspace_user') ->using(WorkspaceUser::class) ->withPivot('role') ->withTimestamps(); } public function getActivitylogOptions(): LogOptions { return LogOptions::defaults() ->logFillable() ->logOnlyDirty() ->dontSubmitEmptyLogs(); } }