*/ protected $dispatchesEvents = [ 'created' => VideoScriptCreated::class, 'deleted' => VideoScriptDeleted::class, 'forceDeleting' => VideoScriptForceDeleting::class, 'restored' => VideoScriptRestored::class, 'updated' => VideoScriptUpdated::class, ]; /** * The attributes that are mass assignable. * * @var list */ protected $fillable = [ VideoScript::ATTRIBUTE_PATH, VideoScript::ATTRIBUTE_VIDEO, ]; /** * Get the attributes that should be cast. * * @return array */ protected function casts(): array { return [ VideoScript::ATTRIBUTE_PATH => 'string', VideoScript::ATTRIBUTE_VIDEO => 'int', ]; } protected function link(): Attribute { return Attribute::make(function (): ?string { // Necessary for 'make' factories. if ($this->getAttribute($this->getRouteKeyName()) !== null) { return route('videoscript.show', $this); } return null; }); } public function getName(): string { return $this->path; } public function getSubtitle(): string { return $this->video->getName(); } /** * @return BelongsTo */ public function video(): BelongsTo { return $this->belongsTo(Video::class, VideoScript::ATTRIBUTE_VIDEO); } /** * Get the schema for the model. */ public function schema(): ScriptSchema { return new ScriptSchema(); } }