[ 'except' => null, ], ]; public function rules() { return [ 'image' => [Rule::requiredIf(!$this->bitcoinEvent->id), 'nullable', 'mimes:jpeg,png,jpg,gif', 'max:10240'], 'bitcoinEvent.venue_id' => 'required', 'bitcoinEvent.from' => 'required', 'bitcoinEvent.to' => 'required', 'bitcoinEvent.title' => 'required', 'bitcoinEvent.description' => 'required', 'bitcoinEvent.link' => 'required|url', 'bitcoinEvent.show_worldwide' => 'bool', ]; } public function mount() { if (!$this->bitcoinEvent) { $this->bitcoinEvent = new BitcoinEvent( [ 'description' => '', 'show_worldwide' => true, ] ); } elseif (!auth() ->user() ->can('update', $this->bitcoinEvent)) { abort(403); } if (!$this->fromUrl) { $this->fromUrl = url()->previous(); } } public function submit() { $this->validate(); $this->bitcoinEvent->save(); if ($this->image) { $this->bitcoinEvent->addMedia($this->image) ->toMediaCollection('logo'); } return redirect($this->fromUrl); } public function render() { return view('livewire.bitcoin-event.form.bitcoin-event-form'); } }