mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-nostr.git
synced 2025-12-13 05:26:47 +00:00
🎨 feat(image): validate and upload project proposal images in the form. Update image preview logic.
This commit is contained in:
@@ -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 () {
|
||||
|
||||
<x-input.group :for=" md5('image')" :label="__('Bild')">
|
||||
<div class="py-4">
|
||||
@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']))
|
||||
<div class="text-gray-200">{{ __('Preview') }}:</div>
|
||||
<img class="h-48 object-contain" src="{{ $image->temporaryUrl() }}">
|
||||
@endif
|
||||
|
||||
@@ -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 () {
|
||||
|
||||
<x-input.group :for=" md5('image')" :label="__('Bild')">
|
||||
<div class="py-4">
|
||||
@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']))
|
||||
<div class="text-gray-200">{{ __('Preview') }}:</div>
|
||||
<img class="h-48 object-contain" src="{{ $image->temporaryUrl() }}">
|
||||
@endif
|
||||
|
||||
@@ -135,9 +135,9 @@ $delete = function ($id) {
|
||||
class="flex bg-white dark:bg-gray-800 shadow-sm rounded-xl overflow-hidden">
|
||||
<!-- Image -->
|
||||
<a class="relative block w-24 sm:w-56 xl:sidebar-expanded:w-40 2xl:sidebar-expanded:w-56 shrink-0"
|
||||
href="{{ route('association.projectSupport.item', ['projectProposal' => $project]) }}">
|
||||
href="{{ route('association.projectSupport.item', ['projectProposal' => $project]) }}">
|
||||
<img class="absolute object-cover object-center w-full h-full"
|
||||
src="{{ asset('einundzwanzig-alpha.jpg') }}" alt="Meetup 01">
|
||||
src="{{ $project->getFirstMediaUrl('main') }}" alt="Meetup 01">
|
||||
<button class="absolute top-0 right-0 mt-4 mr-4">
|
||||
<img class="rounded-full h-8 w-8" src="{{ $project->einundzwanzigPleb->profile->picture }}"
|
||||
alt="">
|
||||
|
||||
Reference in New Issue
Block a user