*/ protected $fillable = [ 'account_id', 'name', 'name_translation_key', 'type', 'can_be_deleted', 'reserved_to_contact_information', 'pagination', ]; /** * The attributes that should be cast to native types. * * @var array */ protected $casts = [ 'can_be_deleted' => 'boolean', 'reserved_to_contact_information' => 'boolean', ]; /** * Get the account associated with the template. * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\App\Models\Account, $this> */ public function account(): BelongsTo { return $this->belongsTo(Account::class); } /** * Get the module rows associated with the module. * * @return \Illuminate\Database\Eloquent\Relations\HasMany<\App\Models\ModuleRow, $this> */ public function rows(): HasMany { return $this->hasMany(ModuleRow::class); } /** * Get the template pages associated with the module. * * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany<\App\Models\TemplatePage, $this> */ public function templatePages(): BelongsToMany { return $this->belongsToMany(TemplatePage::class, 'module_template_page') ->withTimestamps(); } /** * Get the name attribute. * Modules have a default name that can be translated. * Howerer, if a name is set, it will be used instead of the default. * * @return Attribute */ protected function name(): Attribute { return Attribute::make( get: function ($value, $attributes) { if (! $value) { return __($attributes['name_translation_key']); } return $value; }, set: fn ($value) => $value, ); } }