diff --git a/app/Http/Livewire/Tables/BookCaseTable.php b/app/Http/Livewire/Tables/BookCaseTable.php index 1b2f9b2d..b96ef017 100644 --- a/app/Http/Livewire/Tables/BookCaseTable.php +++ b/app/Http/Livewire/Tables/BookCaseTable.php @@ -5,6 +5,7 @@ namespace App\Http\Livewire\Tables; use App\Models\BookCase; use App\Models\OrangePill; use Illuminate\Database\Eloquent\Builder; +use Livewire\WithFileUploads; use Rappasoft\LaravelLivewireTables\DataTableComponent; use Rappasoft\LaravelLivewireTables\Views\Column; use Rappasoft\LaravelLivewireTables\Views\Filters\TextFilter; @@ -12,10 +13,13 @@ use WireUi\Traits\Actions; class BookCaseTable extends DataTableComponent { + use WithFileUploads; use Actions; public string $country; + public $photo; + public bool $viewingModal = false; public $currentModal; public array $orangepill = [ @@ -29,7 +33,7 @@ class BookCaseTable extends DataTableComponent { $this->setPrimaryKey('id') ->setAdditionalSelects(['id', 'homepage']) - ->setDefaultSort('orange_pills_count', 'desc') + ->setDefaultSort('orange_pills_count', 'desc') ->setThAttributes(function (Column $column) { 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', @@ -97,7 +101,9 @@ class BookCaseTable extends DataTableComponent ) ->html(), 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([ 'orangepill.amount' => 'required|numeric', 'orangepill.date' => 'required|date', + 'photo' => 'image|max:4096', // 4MB Max ]); $orangePill = OrangePill::create([ 'user_id' => auth()->id(), @@ -137,6 +144,14 @@ class BookCaseTable extends DataTableComponent 'amount' => $this->orangepill['amount'], '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']) { $this->currentModal->comment($this->orangepill['comment'], null); } diff --git a/app/Models/OrangePill.php b/app/Models/OrangePill.php index d25468d4..5d9ea0b4 100644 --- a/app/Models/OrangePill.php +++ b/app/Models/OrangePill.php @@ -6,10 +6,15 @@ use App\Gamify\Points\BookCaseOrangePilled; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; 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 InteractsWithMedia; /** * 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 { return $this->belongsTo(User::class); diff --git a/config/media-library.php b/config/media-library.php index 825ccc07..e76509cb 100644 --- a/config/media-library.php +++ b/config/media-library.php @@ -29,7 +29,7 @@ return [ /* * 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. diff --git a/resources/lang/de.json b/resources/lang/de.json index ddb2b4a3..1d4e9b2b 100644 --- a/resources/lang/de.json +++ b/resources/lang/de.json @@ -639,5 +639,7 @@ "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.", "You get a point when you log in.": "Du bekommst einen Punkt, wenn du dich einloggst.", - "has": "hat" -} + "has": "hat", + "logins": "", + "points": "" +} \ No newline at end of file diff --git a/resources/lang/en.json b/resources/lang/en.json index 96f95e7f..2d82c7e8 100644 --- a/resources/lang/en.json +++ b/resources/lang/en.json @@ -631,5 +631,7 @@ "This lecturer has not yet written an introduction.": "", "If your city is not listed, please create it first.": "", "You get a point when you log in.": "", - "has": "" -} + "has": "", + "logins": "", + "points": "" +} \ No newline at end of file diff --git a/resources/lang/es.json b/resources/lang/es.json index 51d15f45..930548de 100644 --- a/resources/lang/es.json +++ b/resources/lang/es.json @@ -622,5 +622,17 @@ "Back": "", "By 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.": "" } \ No newline at end of file diff --git a/resources/lang/fr.json b/resources/lang/fr.json index 7c7e9dcb..c1d0b077 100644 --- a/resources/lang/fr.json +++ b/resources/lang/fr.json @@ -622,5 +622,17 @@ "Back": "", "By 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.": "" } \ No newline at end of file diff --git a/resources/lang/hr.json b/resources/lang/hr.json index 6c483930..5e0d7637 100644 --- a/resources/lang/hr.json +++ b/resources/lang/hr.json @@ -622,5 +622,17 @@ "Back": "", "By 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.": "" } \ No newline at end of file diff --git a/resources/lang/it.json b/resources/lang/it.json index c322d780..43ef5d98 100644 --- a/resources/lang/it.json +++ b/resources/lang/it.json @@ -622,5 +622,17 @@ "Back": "", "By 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.": "" } \ No newline at end of file diff --git a/resources/lang/mk.json b/resources/lang/mk.json index 3bf1b77f..d1cdb208 100644 --- a/resources/lang/mk.json +++ b/resources/lang/mk.json @@ -622,5 +622,17 @@ "Back": "", "By 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.": "" } \ No newline at end of file diff --git a/resources/lang/pl.json b/resources/lang/pl.json index 2a212c1a..76697d3a 100644 --- a/resources/lang/pl.json +++ b/resources/lang/pl.json @@ -622,5 +622,17 @@ "Back": "", "By 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.": "" } \ No newline at end of file diff --git a/resources/lang/pt.json b/resources/lang/pt.json index 3ffa2725..fc77c8cd 100644 --- a/resources/lang/pt.json +++ b/resources/lang/pt.json @@ -622,5 +622,17 @@ "Back": "", "By 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.": "" } \ No newline at end of file diff --git a/resources/lang/tr.json b/resources/lang/tr.json index 9883660f..63feb83f 100644 --- a/resources/lang/tr.json +++ b/resources/lang/tr.json @@ -596,5 +596,17 @@ "Back": "", "By 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.": "" } \ No newline at end of file diff --git a/resources/views/livewire/book-case/highscore-table.blade.php b/resources/views/livewire/book-case/highscore-table.blade.php index a9ee45db..00cfc45d 100644 --- a/resources/views/livewire/book-case/highscore-table.blade.php +++ b/resources/views/livewire/book-case/highscore-table.blade.php @@ -103,7 +103,7 @@
book_case
diff --git a/resources/views/modals/book_cases/orange_pill.blade.php b/resources/views/modals/book_cases/orange_pill.blade.php index 99feef0d..e9835fbc 100644 --- a/resources/views/modals/book_cases/orange_pill.blade.php +++ b/resources/views/modals/book_cases/orange_pill.blade.php @@ -27,6 +27,16 @@ +
+
+ +
+ + @error('photo') {{ $message }} @enderror +
+
+
+