'', 'year' => '', ]; public $showCreateModal = false; public function mount(Project $project) { $this->path = $project->download_path; } public function render() { return view('livewire.projects.mosaic-manager', [ 'downloads' => $this->project ]); } public function saveMosaic(){ $this->validate([ 'formData.year' => 'required', 'formData.week' => 'required', ]); $mosaic = $this->project->mosaics()->updateOrCreate([ 'name' => sprintf('Week %s, %s', $this->formData['week'], $this->formData['year']), 'year' => $this->formData['year'], 'week' => $this->formData['week'], ],[ 'path' => $this->project->getMosaicPath(), ]); ProjectMosiacGeneratorJob::dispatch($mosaic); $this->showCreateModal = false; } public function openCreateMosiacsModal(){ $this->showCreateModal = true; } public function getDateRangeProperty() { if (empty($this->formData['week']) || strlen($this->formData['year']) !== 4) { return 'Invalid week or year'; } $begin = now() ->setISODate($this->formData['year'], $this->formData['week']) ->startOfWeek(); $end = now() ->setISODate($this->formData['year'], $this->formData['week']) ->endOfWeek(); return $begin->format('Y-m-d').' - '.$end->format('Y-m-d'); } }