fix: adding ability to update artist bg
This commit is contained in:
48
site/app/Livewire/Artist/Header.php
Normal file
48
site/app/Livewire/Artist/Header.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire\Artist;
|
||||
|
||||
use Livewire\Component;
|
||||
use Livewire\WithFileUploads;
|
||||
use Spatie\Image\Image;
|
||||
use Intervention\Image\Facades\Image as InterventionImage;
|
||||
use ImageOptimizer;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Validation\Rules\File;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Livewire\Attributes\Validate;
|
||||
|
||||
class Header extends Component
|
||||
{
|
||||
use WithFileUploads;
|
||||
|
||||
public $header;
|
||||
|
||||
public $x;
|
||||
public $y;
|
||||
public $width;
|
||||
public $height;
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.artist.header');
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$disk = Storage::disk('static');
|
||||
$header = $this->header->store('artist_headers', 'static');
|
||||
|
||||
Image::load($disk->path($header))
|
||||
->manualCrop($this->width, $this->height, $this->x, $this->y)
|
||||
->save();
|
||||
Image::load($disk->path($header))
|
||||
->width(270)
|
||||
->height(185)
|
||||
->save();
|
||||
ImageOptimizer::optimize($disk->path($header));
|
||||
auth()->user()->artists()->first()->update(compact('header'));
|
||||
$this->header = null;
|
||||
return redirect(request()->header('Referer'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user