diff --git a/resources/views/pages/association/project-support/form/[ProjectProposal:slug].blade.php b/resources/views/pages/association/project-support/form/[ProjectProposal:slug].blade.php index a7af089..9a64ba9 100644 --- a/resources/views/pages/association/project-support/form/[ProjectProposal:slug].blade.php +++ b/resources/views/pages/association/project-support/form/[ProjectProposal:slug].blade.php @@ -50,6 +50,14 @@ on([ $save = function () { $this->form->validate(); + if ($this->image) { + $this->validate([ + 'image' => 'image|max:1024', + ]); + $this->projectProposal + ->addMedia($this->image->getRealPath()) + ->toMediaCollection('main'); + } $this->projectProposal->update([ ...$this->form->except('id', 'slug'), @@ -71,7 +79,7 @@ $save = function () {
- @if ($image && str($image->getMimeType())->contains(['image/jpeg','image/jpg', 'image/png', 'image/gif', 'image/svg+xml', 'image/webp'])) + @if ($image && method_exists($image, 'temporaryUrl') && str($image->getMimeType())->contains(['image/jpeg','image/jpg', 'image/png', 'image/gif', 'image/svg+xml', 'image/webp']))
{{ __('Preview') }}:
@endif diff --git a/resources/views/pages/association/project-support/form/create.blade.php b/resources/views/pages/association/project-support/form/create.blade.php index aa8064a..84eaf6a 100644 --- a/resources/views/pages/association/project-support/form/create.blade.php +++ b/resources/views/pages/association/project-support/form/create.blade.php @@ -45,10 +45,20 @@ on([ $save = function () { $this->form->validate(); - \App\Models\ProjectProposal::query()->create([ + $this->validate('image', 'image|max:1024'); + + $projectProposal = \App\Models\ProjectProposal::query()->create([ ...$this->form->all(), 'einundzwanzig_pleb_id' => $this->currentPleb->id, ]); + if ($this->image) { + $this->validate([ + 'image' => 'image|max:1024', + ]); + $projectProposal + ->addMedia($this->image->getRealPath()) + ->toMediaCollection('main'); + } return redirect()->route('association.projectSupport'); }; @@ -65,7 +75,7 @@ $save = function () {
- @if ($image && str($image->getMimeType())->contains(['image/jpeg','image/jpg', 'image/png', 'image/gif', 'image/svg+xml', 'image/webp'])) + @if ($image && method_exists($image, 'temporaryUrl') && str($image->getMimeType())->contains(['image/jpeg','image/jpg', 'image/png', 'image/gif', 'image/svg+xml', 'image/webp']))
{{ __('Preview') }}:
@endif diff --git a/resources/views/pages/association/project-support/index.blade.php b/resources/views/pages/association/project-support/index.blade.php index fac7df4..3e6b0d5 100644 --- a/resources/views/pages/association/project-support/index.blade.php +++ b/resources/views/pages/association/project-support/index.blade.php @@ -135,9 +135,9 @@ $delete = function ($id) { class="flex bg-white dark:bg-gray-800 shadow-sm rounded-xl overflow-hidden"> + href="{{ route('association.projectSupport.item', ['projectProposal' => $project]) }}"> Meetup 01 + src="{{ $project->getFirstMediaUrl('main') }}" alt="Meetup 01">