fix: modifying borken profile items (#7)
Reviewed-on: #7 Co-authored-by: Paul Couture <paul@paulcouture.com> Co-committed-by: Paul Couture <paul@paulcouture.com>
This commit is contained in:
parent
a989f3e92b
commit
b14a77762d
@ -23,6 +23,7 @@ public function index()
|
|||||||
$user = auth()->user();
|
$user = auth()->user();
|
||||||
$artists = Artist::whereHas('artworks')
|
$artists = Artist::whereHas('artworks')
|
||||||
->withCount('artworks')
|
->withCount('artworks')
|
||||||
|
->withCount('episodes')
|
||||||
->orderBy('artworks_count', 'desc')
|
->orderBy('artworks_count', 'desc')
|
||||||
->paginate(100);
|
->paginate(100);
|
||||||
$podcasts = Podcast::where('published', true)->get();
|
$podcasts = Podcast::where('published', true)->get();
|
||||||
@ -65,6 +66,8 @@ public function show(Request $request, $slug)
|
|||||||
{
|
{
|
||||||
$user = auth()->user();
|
$user = auth()->user();
|
||||||
$artist = Artist::where('slug', $slug)
|
$artist = Artist::where('slug', $slug)
|
||||||
|
->withCount('episodes')
|
||||||
|
->withCount('artworks')
|
||||||
->firstOrFail();
|
->firstOrFail();
|
||||||
$artworks = Artwork::where('artist_id', $artist->id)
|
$artworks = Artwork::where('artist_id', $artist->id)
|
||||||
->with('episode')
|
->with('episode')
|
||||||
|
36
site/app/Jobs/OptimizeArtistHeaderJob.php
Normal file
36
site/app/Jobs/OptimizeArtistHeaderJob.php
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use ImageOptimizer;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class OptimizeArtistHeaderJob implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
private $path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*/
|
||||||
|
public function __construct($path)
|
||||||
|
{
|
||||||
|
$this->path = $path;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*/
|
||||||
|
public function handle(): void
|
||||||
|
{
|
||||||
|
Log::info('Header: Optimizing ' . $this->path);
|
||||||
|
ImageOptimizer::optimize($this->path);
|
||||||
|
}
|
||||||
|
}
|
36
site/app/Jobs/OptimizeAvatarJob.php
Normal file
36
site/app/Jobs/OptimizeAvatarJob.php
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use ImageOptimizer;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class OptimizeAvatarJob implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
private $path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*/
|
||||||
|
public function __construct($path)
|
||||||
|
{
|
||||||
|
$this->path = $path;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*/
|
||||||
|
public function handle(): void
|
||||||
|
{
|
||||||
|
Log::info('Avatar: Optimizing ' . $this->path);
|
||||||
|
ImageOptimizer::optimize($this->path);
|
||||||
|
}
|
||||||
|
}
|
@ -11,6 +11,8 @@
|
|||||||
use Illuminate\Validation\Rules\File;
|
use Illuminate\Validation\Rules\File;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Livewire\Attributes\Validate;
|
use Livewire\Attributes\Validate;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use App\Jobs\OptimizeAvatarJob;
|
||||||
|
|
||||||
class Avatar extends Component
|
class Avatar extends Component
|
||||||
{
|
{
|
||||||
@ -32,7 +34,6 @@ public function save()
|
|||||||
{
|
{
|
||||||
$disk = Storage::disk('static');
|
$disk = Storage::disk('static');
|
||||||
$avatar = $this->avatar->store('avatars', 'static');
|
$avatar = $this->avatar->store('avatars', 'static');
|
||||||
|
|
||||||
Image::load($disk->path($avatar))
|
Image::load($disk->path($avatar))
|
||||||
->manualCrop($this->width, $this->height, $this->x, $this->y)
|
->manualCrop($this->width, $this->height, $this->x, $this->y)
|
||||||
->save();
|
->save();
|
||||||
@ -40,7 +41,9 @@ public function save()
|
|||||||
->width(350)
|
->width(350)
|
||||||
->height(350)
|
->height(350)
|
||||||
->save();
|
->save();
|
||||||
ImageOptimizer::optimize($disk->path($avatar));
|
Log::info('Avatar: Optimizing ' . $disk->path($avatar));
|
||||||
|
OptimizeAvatarJob::dispatchSync($disk->path($avatar));
|
||||||
|
//ImageOptimizer::optimize($disk->path($avatar));
|
||||||
auth()->user()->artists()->first()->update(compact('avatar'));
|
auth()->user()->artists()->first()->update(compact('avatar'));
|
||||||
$this->avatar = null;
|
$this->avatar = null;
|
||||||
return redirect(request()->header('Referer'));
|
return redirect(request()->header('Referer'));
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
use Illuminate\Validation\Rules\File;
|
use Illuminate\Validation\Rules\File;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Livewire\Attributes\Validate;
|
use Livewire\Attributes\Validate;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use App\Jobs\OptimizeArtistHeaderJob;
|
||||||
|
|
||||||
class Header extends Component
|
class Header extends Component
|
||||||
{
|
{
|
||||||
@ -32,7 +34,6 @@ public function save()
|
|||||||
{
|
{
|
||||||
$disk = Storage::disk('static');
|
$disk = Storage::disk('static');
|
||||||
$header = $this->header->store('artist_headers', 'static');
|
$header = $this->header->store('artist_headers', 'static');
|
||||||
|
|
||||||
Image::load($disk->path($header))
|
Image::load($disk->path($header))
|
||||||
->manualCrop($this->width, $this->height, $this->x, $this->y)
|
->manualCrop($this->width, $this->height, $this->x, $this->y)
|
||||||
->save();
|
->save();
|
||||||
@ -40,7 +41,8 @@ public function save()
|
|||||||
->width(270)
|
->width(270)
|
||||||
->height(185)
|
->height(185)
|
||||||
->save();
|
->save();
|
||||||
ImageOptimizer::optimize($disk->path($header));
|
Log::info('Avatar: Optimizing ' . $disk->path($header));
|
||||||
|
OptimizeArtistHeaderJob::dispatchSync($disk->path($header));
|
||||||
auth()->user()->artists()->first()->update(compact('header'));
|
auth()->user()->artists()->first()->update(compact('header'));
|
||||||
$this->header = null;
|
$this->header = null;
|
||||||
return redirect(request()->header('Referer'));
|
return redirect(request()->header('Referer'));
|
||||||
|
@ -21,7 +21,8 @@
|
|||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
<div class="size-small justify-content-center mb-4">
|
<div class="size-small justify-content-center mb-4">
|
||||||
{{ number_format($artist->artworks->count()) }} Submitted Artworks
|
{{ number_format($artist->artworks_count) }} Submitted Artworks<br>
|
||||||
|
{{ number_format($artist->episodes_count) }} Artworks Selected
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user