toActionResult()->hasFailed()) { return null; } return $this->getOrCreateScript(); } /** * Get existing or create new script for file upload. * * @return VideoScript */ protected function getOrCreateScript(): VideoScript { $path = Str::of($this->path) ->finish(DIRECTORY_SEPARATOR) ->append($this->file->getClientOriginalName()) ->__toString(); $attributes = [ VideoScript::ATTRIBUTE_PATH => $path, ]; if ($this->video !== null) { $attributes[VideoScript::ATTRIBUTE_VIDEO] = $this->video->getKey(); } return VideoScript::updateOrCreate( [ VideoScript::ATTRIBUTE_PATH => $path, ], $attributes ); } /** * The list of disk names. * * @return array */ public function disks(): array { return Arr::wrap(Config::get(VideoConstants::SCRIPT_DISK_QUALIFIED)); } }