From e65ad29aadf3cbe0a8e35468f03a3994e2657d03 Mon Sep 17 00:00:00 2001 From: HolgerHatGarKeineNode Date: Sat, 11 Feb 2023 13:57:01 +0100 Subject: [PATCH] Rule::requiredIf(!$this->libraryItem->id) --- app/Http/Livewire/News/Form/NewsArticleForm.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Http/Livewire/News/Form/NewsArticleForm.php b/app/Http/Livewire/News/Form/NewsArticleForm.php index fa20323d..c4162342 100644 --- a/app/Http/Livewire/News/Form/NewsArticleForm.php +++ b/app/Http/Livewire/News/Form/NewsArticleForm.php @@ -67,8 +67,10 @@ class NewsArticleForm extends Component $this->validate(); $this->libraryItem->save(); - $this->libraryItem->addMedia($this->image) - ->toMediaCollection('main'); + if ($this->image) { + $this->libraryItem->addMedia($this->image) + ->toMediaCollection('main'); + } return to_route('article.overview', ['country' => null]); }