mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
images
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Http\Livewire\Tables;
|
|||||||
use App\Models\BookCase;
|
use App\Models\BookCase;
|
||||||
use App\Models\OrangePill;
|
use App\Models\OrangePill;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Livewire\WithFileUploads;
|
||||||
use Rappasoft\LaravelLivewireTables\DataTableComponent;
|
use Rappasoft\LaravelLivewireTables\DataTableComponent;
|
||||||
use Rappasoft\LaravelLivewireTables\Views\Column;
|
use Rappasoft\LaravelLivewireTables\Views\Column;
|
||||||
use Rappasoft\LaravelLivewireTables\Views\Filters\TextFilter;
|
use Rappasoft\LaravelLivewireTables\Views\Filters\TextFilter;
|
||||||
@@ -12,10 +13,13 @@ use WireUi\Traits\Actions;
|
|||||||
|
|
||||||
class BookCaseTable extends DataTableComponent
|
class BookCaseTable extends DataTableComponent
|
||||||
{
|
{
|
||||||
|
use WithFileUploads;
|
||||||
use Actions;
|
use Actions;
|
||||||
|
|
||||||
public string $country;
|
public string $country;
|
||||||
|
|
||||||
|
public $photo;
|
||||||
|
|
||||||
public bool $viewingModal = false;
|
public bool $viewingModal = false;
|
||||||
public $currentModal;
|
public $currentModal;
|
||||||
public array $orangepill = [
|
public array $orangepill = [
|
||||||
@@ -29,7 +33,7 @@ class BookCaseTable extends DataTableComponent
|
|||||||
{
|
{
|
||||||
$this->setPrimaryKey('id')
|
$this->setPrimaryKey('id')
|
||||||
->setAdditionalSelects(['id', 'homepage'])
|
->setAdditionalSelects(['id', 'homepage'])
|
||||||
->setDefaultSort('orange_pills_count', 'desc')
|
->setDefaultSort('orange_pills_count', 'desc')
|
||||||
->setThAttributes(function (Column $column) {
|
->setThAttributes(function (Column $column) {
|
||||||
return [
|
return [
|
||||||
'class' => 'px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider dark:bg-gray-800 dark:text-gray-400',
|
'class' => 'px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider dark:bg-gray-800 dark:text-gray-400',
|
||||||
@@ -97,7 +101,9 @@ class BookCaseTable extends DataTableComponent
|
|||||||
)
|
)
|
||||||
->html(),
|
->html(),
|
||||||
Column::make('Orange-Pilled', 'orange_pilled')
|
Column::make('Orange-Pilled', 'orange_pilled')
|
||||||
->label(fn($row, Column $column) => view('columns.book_cases.oranged-pilled')->withRow($row)->withCountry($this->country))
|
->label(fn($row, Column $column) => view('columns.book_cases.oranged-pilled')
|
||||||
|
->withRow($row)
|
||||||
|
->withCountry($this->country))
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,6 +136,7 @@ class BookCaseTable extends DataTableComponent
|
|||||||
$this->validate([
|
$this->validate([
|
||||||
'orangepill.amount' => 'required|numeric',
|
'orangepill.amount' => 'required|numeric',
|
||||||
'orangepill.date' => 'required|date',
|
'orangepill.date' => 'required|date',
|
||||||
|
'photo' => 'image|max:4096', // 4MB Max
|
||||||
]);
|
]);
|
||||||
$orangePill = OrangePill::create([
|
$orangePill = OrangePill::create([
|
||||||
'user_id' => auth()->id(),
|
'user_id' => auth()->id(),
|
||||||
@@ -137,6 +144,14 @@ class BookCaseTable extends DataTableComponent
|
|||||||
'amount' => $this->orangepill['amount'],
|
'amount' => $this->orangepill['amount'],
|
||||||
'date' => $this->orangepill['date'],
|
'date' => $this->orangepill['date'],
|
||||||
]);
|
]);
|
||||||
|
$orangePill
|
||||||
|
->addMedia($this->photo)
|
||||||
|
->preservingOriginal()
|
||||||
|
->toMediaCollection('images');
|
||||||
|
$orangePill->load(['media']);
|
||||||
|
$this->currentModal
|
||||||
|
->addMedia($this->photo)
|
||||||
|
->toMediaCollection('images');
|
||||||
if ($this->orangepill['comment']) {
|
if ($this->orangepill['comment']) {
|
||||||
$this->currentModal->comment($this->orangepill['comment'], null);
|
$this->currentModal->comment($this->orangepill['comment'], null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,10 +6,15 @@ use App\Gamify\Points\BookCaseOrangePilled;
|
|||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
use Spatie\Image\Manipulations;
|
||||||
|
use Spatie\MediaLibrary\HasMedia;
|
||||||
|
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||||
|
use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
||||||
|
|
||||||
class OrangePill extends Model
|
class OrangePill extends Model implements HasMedia
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
use InteractsWithMedia;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The attributes that aren't mass assignable.
|
* The attributes that aren't mass assignable.
|
||||||
@@ -35,6 +40,23 @@ class OrangePill extends Model
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function registerMediaConversions(Media $media = null): void
|
||||||
|
{
|
||||||
|
$this
|
||||||
|
->addMediaConversion('preview')
|
||||||
|
->fit(Manipulations::FIT_CROP, 300, 300)
|
||||||
|
->nonQueued();
|
||||||
|
$this->addMediaConversion('thumb')
|
||||||
|
->fit(Manipulations::FIT_CROP, 130, 130)
|
||||||
|
->width(130)
|
||||||
|
->height(130);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function registerMediaCollections(): void
|
||||||
|
{
|
||||||
|
$this->addMediaCollection('images');
|
||||||
|
}
|
||||||
|
|
||||||
public function user(): BelongsTo
|
public function user(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(User::class);
|
return $this->belongsTo(User::class);
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ return [
|
|||||||
/*
|
/*
|
||||||
* By default all conversions will be performed on a queue.
|
* By default all conversions will be performed on a queue.
|
||||||
*/
|
*/
|
||||||
'queue_conversions_by_default' => env('QUEUE_CONVERSIONS_BY_DEFAULT', true),
|
'queue_conversions_by_default' => env('QUEUE_CONVERSIONS_BY_DEFAULT', false),
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The fully qualified class name of the media model.
|
* The fully qualified class name of the media model.
|
||||||
|
|||||||
@@ -639,5 +639,7 @@
|
|||||||
"This lecturer has not yet written an introduction.": "Dieser Dozent hat noch keine Einführung geschrieben.",
|
"This lecturer has not yet written an introduction.": "Dieser Dozent hat noch keine Einführung geschrieben.",
|
||||||
"If your city is not listed, please create it first.": "Wenn deine Stadt nicht aufgeführt ist, erstelle sie bitte zuerst.",
|
"If your city is not listed, please create it first.": "Wenn deine Stadt nicht aufgeführt ist, erstelle sie bitte zuerst.",
|
||||||
"You get a point when you log in.": "Du bekommst einen Punkt, wenn du dich einloggst.",
|
"You get a point when you log in.": "Du bekommst einen Punkt, wenn du dich einloggst.",
|
||||||
"has": "hat"
|
"has": "hat",
|
||||||
|
"logins": "",
|
||||||
|
"points": ""
|
||||||
}
|
}
|
||||||
@@ -631,5 +631,7 @@
|
|||||||
"This lecturer has not yet written an introduction.": "",
|
"This lecturer has not yet written an introduction.": "",
|
||||||
"If your city is not listed, please create it first.": "",
|
"If your city is not listed, please create it first.": "",
|
||||||
"You get a point when you log in.": "",
|
"You get a point when you log in.": "",
|
||||||
"has": ""
|
"has": "",
|
||||||
|
"logins": "",
|
||||||
|
"points": ""
|
||||||
}
|
}
|
||||||
@@ -622,5 +622,17 @@
|
|||||||
"Back": "",
|
"Back": "",
|
||||||
"By lecturer": "",
|
"By lecturer": "",
|
||||||
"All courses of this lecturer": "",
|
"All courses of this lecturer": "",
|
||||||
"Here you can see all events of this lecturer.": ""
|
"Here you can see all events of this lecturer.": "",
|
||||||
|
"This lecturer has not yet written an introduction.": "",
|
||||||
|
"Subtitle": "",
|
||||||
|
"This is the subtitle on the landing page.": "",
|
||||||
|
"Intro": "",
|
||||||
|
"This is the introduction text that is shown on the landing page.": "",
|
||||||
|
"If your city is not listed, please create it first.": "",
|
||||||
|
"has": "",
|
||||||
|
"logins": "",
|
||||||
|
"You get a point when you log in.": "",
|
||||||
|
"points": "",
|
||||||
|
"All courses of :name": "",
|
||||||
|
"Here you can see all events of :name.": ""
|
||||||
}
|
}
|
||||||
@@ -622,5 +622,17 @@
|
|||||||
"Back": "",
|
"Back": "",
|
||||||
"By lecturer": "",
|
"By lecturer": "",
|
||||||
"All courses of this lecturer": "",
|
"All courses of this lecturer": "",
|
||||||
"Here you can see all events of this lecturer.": ""
|
"Here you can see all events of this lecturer.": "",
|
||||||
|
"This lecturer has not yet written an introduction.": "",
|
||||||
|
"Subtitle": "",
|
||||||
|
"This is the subtitle on the landing page.": "",
|
||||||
|
"Intro": "",
|
||||||
|
"This is the introduction text that is shown on the landing page.": "",
|
||||||
|
"If your city is not listed, please create it first.": "",
|
||||||
|
"has": "",
|
||||||
|
"logins": "",
|
||||||
|
"You get a point when you log in.": "",
|
||||||
|
"points": "",
|
||||||
|
"All courses of :name": "",
|
||||||
|
"Here you can see all events of :name.": ""
|
||||||
}
|
}
|
||||||
@@ -622,5 +622,17 @@
|
|||||||
"Back": "",
|
"Back": "",
|
||||||
"By lecturer": "",
|
"By lecturer": "",
|
||||||
"All courses of this lecturer": "",
|
"All courses of this lecturer": "",
|
||||||
"Here you can see all events of this lecturer.": ""
|
"Here you can see all events of this lecturer.": "",
|
||||||
|
"This lecturer has not yet written an introduction.": "",
|
||||||
|
"Subtitle": "",
|
||||||
|
"This is the subtitle on the landing page.": "",
|
||||||
|
"Intro": "",
|
||||||
|
"This is the introduction text that is shown on the landing page.": "",
|
||||||
|
"If your city is not listed, please create it first.": "",
|
||||||
|
"has": "",
|
||||||
|
"logins": "",
|
||||||
|
"You get a point when you log in.": "",
|
||||||
|
"points": "",
|
||||||
|
"All courses of :name": "",
|
||||||
|
"Here you can see all events of :name.": ""
|
||||||
}
|
}
|
||||||
@@ -622,5 +622,17 @@
|
|||||||
"Back": "",
|
"Back": "",
|
||||||
"By lecturer": "",
|
"By lecturer": "",
|
||||||
"All courses of this lecturer": "",
|
"All courses of this lecturer": "",
|
||||||
"Here you can see all events of this lecturer.": ""
|
"Here you can see all events of this lecturer.": "",
|
||||||
|
"This lecturer has not yet written an introduction.": "",
|
||||||
|
"Subtitle": "",
|
||||||
|
"This is the subtitle on the landing page.": "",
|
||||||
|
"Intro": "",
|
||||||
|
"This is the introduction text that is shown on the landing page.": "",
|
||||||
|
"If your city is not listed, please create it first.": "",
|
||||||
|
"has": "",
|
||||||
|
"logins": "",
|
||||||
|
"You get a point when you log in.": "",
|
||||||
|
"points": "",
|
||||||
|
"All courses of :name": "",
|
||||||
|
"Here you can see all events of :name.": ""
|
||||||
}
|
}
|
||||||
@@ -622,5 +622,17 @@
|
|||||||
"Back": "",
|
"Back": "",
|
||||||
"By lecturer": "",
|
"By lecturer": "",
|
||||||
"All courses of this lecturer": "",
|
"All courses of this lecturer": "",
|
||||||
"Here you can see all events of this lecturer.": ""
|
"Here you can see all events of this lecturer.": "",
|
||||||
|
"This lecturer has not yet written an introduction.": "",
|
||||||
|
"Subtitle": "",
|
||||||
|
"This is the subtitle on the landing page.": "",
|
||||||
|
"Intro": "",
|
||||||
|
"This is the introduction text that is shown on the landing page.": "",
|
||||||
|
"If your city is not listed, please create it first.": "",
|
||||||
|
"has": "",
|
||||||
|
"logins": "",
|
||||||
|
"You get a point when you log in.": "",
|
||||||
|
"points": "",
|
||||||
|
"All courses of :name": "",
|
||||||
|
"Here you can see all events of :name.": ""
|
||||||
}
|
}
|
||||||
@@ -622,5 +622,17 @@
|
|||||||
"Back": "",
|
"Back": "",
|
||||||
"By lecturer": "",
|
"By lecturer": "",
|
||||||
"All courses of this lecturer": "",
|
"All courses of this lecturer": "",
|
||||||
"Here you can see all events of this lecturer.": ""
|
"Here you can see all events of this lecturer.": "",
|
||||||
|
"This lecturer has not yet written an introduction.": "",
|
||||||
|
"Subtitle": "",
|
||||||
|
"This is the subtitle on the landing page.": "",
|
||||||
|
"Intro": "",
|
||||||
|
"This is the introduction text that is shown on the landing page.": "",
|
||||||
|
"If your city is not listed, please create it first.": "",
|
||||||
|
"has": "",
|
||||||
|
"logins": "",
|
||||||
|
"You get a point when you log in.": "",
|
||||||
|
"points": "",
|
||||||
|
"All courses of :name": "",
|
||||||
|
"Here you can see all events of :name.": ""
|
||||||
}
|
}
|
||||||
@@ -622,5 +622,17 @@
|
|||||||
"Back": "",
|
"Back": "",
|
||||||
"By lecturer": "",
|
"By lecturer": "",
|
||||||
"All courses of this lecturer": "",
|
"All courses of this lecturer": "",
|
||||||
"Here you can see all events of this lecturer.": ""
|
"Here you can see all events of this lecturer.": "",
|
||||||
|
"This lecturer has not yet written an introduction.": "",
|
||||||
|
"Subtitle": "",
|
||||||
|
"This is the subtitle on the landing page.": "",
|
||||||
|
"Intro": "",
|
||||||
|
"This is the introduction text that is shown on the landing page.": "",
|
||||||
|
"If your city is not listed, please create it first.": "",
|
||||||
|
"has": "",
|
||||||
|
"logins": "",
|
||||||
|
"You get a point when you log in.": "",
|
||||||
|
"points": "",
|
||||||
|
"All courses of :name": "",
|
||||||
|
"Here you can see all events of :name.": ""
|
||||||
}
|
}
|
||||||
@@ -596,5 +596,17 @@
|
|||||||
"Back": "",
|
"Back": "",
|
||||||
"By lecturer": "",
|
"By lecturer": "",
|
||||||
"All courses of this lecturer": "",
|
"All courses of this lecturer": "",
|
||||||
"Here you can see all events of this lecturer.": ""
|
"Here you can see all events of this lecturer.": "",
|
||||||
|
"This lecturer has not yet written an introduction.": "",
|
||||||
|
"Subtitle": "",
|
||||||
|
"This is the subtitle on the landing page.": "",
|
||||||
|
"Intro": "",
|
||||||
|
"This is the introduction text that is shown on the landing page.": "",
|
||||||
|
"If your city is not listed, please create it first.": "",
|
||||||
|
"has": "",
|
||||||
|
"logins": "",
|
||||||
|
"You get a point when you log in.": "",
|
||||||
|
"points": "",
|
||||||
|
"All courses of :name": "",
|
||||||
|
"Here you can see all events of :name.": ""
|
||||||
}
|
}
|
||||||
@@ -103,7 +103,7 @@
|
|||||||
<div
|
<div
|
||||||
class="group aspect-w-10 aspect-h-10 block w-full overflow-hidden rounded-lg bg-gray-100 focus-within:ring-2 focus-within:ring-indigo-500 focus-within:ring-offset-2 focus-within:ring-offset-gray-100">
|
class="group aspect-w-10 aspect-h-10 block w-full overflow-hidden rounded-lg bg-gray-100 focus-within:ring-2 focus-within:ring-indigo-500 focus-within:ring-offset-2 focus-within:ring-offset-gray-100">
|
||||||
<img
|
<img
|
||||||
src="{{ $orangePill->bookCase->getFirstMediaUrl('images') ? $orangePill->bookCase->getFirstMediaUrl('images') : asset('img/empty_book_case.webp') }}"
|
src="{{ $orangePill->getFirstMediaUrl('images') ? $orangePill->bookCase->getFirstMediaUrl('images') ?: asset('img/empty_book_case.webp') : asset('img/empty_book_case.webp') }}"
|
||||||
alt="book_case"
|
alt="book_case"
|
||||||
class="pointer-events-none object-cover group-hover:opacity-75">
|
class="pointer-events-none object-cover group-hover:opacity-75">
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -27,6 +27,16 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="col-span-6 sm:col-span-4">
|
||||||
|
<form wire:submit.prevent="save">
|
||||||
|
<label class="my-2 text-gray-200 text-xl">{{ __('Photo') }}</label>
|
||||||
|
<div class="text-sm text-gray-500">
|
||||||
|
<input type="file" wire:model="photo">
|
||||||
|
@error('photo') <span class="text-red-500">{{ $message }}</span> @enderror
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="col-span-6 sm:col-span-4">
|
<div class="col-span-6 sm:col-span-4">
|
||||||
<x-input
|
<x-input
|
||||||
min="1"
|
min="1"
|
||||||
|
|||||||
Reference in New Issue
Block a user