fix: adding ability to update artist bg
This commit is contained in:
parent
87198b46a5
commit
a156a44130
@ -36,6 +36,10 @@ public function save()
|
|||||||
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();
|
||||||
|
Image::load($disk->path($avatar))
|
||||||
|
->width(350)
|
||||||
|
->height(350)
|
||||||
|
->save();
|
||||||
ImageOptimizer::optimize($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;
|
||||||
|
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'));
|
||||||
|
}
|
||||||
|
}
|
@ -64,9 +64,17 @@ public function wallets()
|
|||||||
public function avatar()
|
public function avatar()
|
||||||
{
|
{
|
||||||
if (!$this->avatar) {
|
if (!$this->avatar) {
|
||||||
return config('app.static_asset_url') . '/' . ('avatars/default_avatar_male.svg');
|
return config('app.static_asset_url') . '/avatars/default_avatar_male.svg';
|
||||||
}
|
}
|
||||||
return config('app.static_asset_url') . '/' . $this->avatar;
|
return config('app.static_asset_url') . '/' . $this->avatar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function header()
|
||||||
|
{
|
||||||
|
if (!$this->header) {
|
||||||
|
return config('app.static_asset_url') . '/artist_headers/default_artist_banner.png';
|
||||||
|
}
|
||||||
|
return config('app.static_asset_url') . '/' . $this->header;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ class="d-flex flex-column justify-content-center"
|
|||||||
x-init="setUp"
|
x-init="setUp"
|
||||||
>
|
>
|
||||||
<div class="d-flex justify-content-center text-center mt-4 mb-4">
|
<div class="d-flex justify-content-center text-center mt-4 mb-4">
|
||||||
<img id="avatar" src="{{ $avatar->temporaryUrl() }}" style="width: 100%; max-width: 100%;">
|
<img id="avatar" src="{{ $avatar->temporaryUrl() }}" style="width: 100%; max-width: 350px; margin:5px auto;">
|
||||||
</div>
|
</div>
|
||||||
<div class="d-flex justify-content-end text-end mt-4 mb-4">
|
<div class="d-flex justify-content-end text-end mt-4 mb-4">
|
||||||
<button type="submit" class="btn btn-gradient btn-small">
|
<button type="submit" class="btn btn-gradient btn-small">
|
||||||
@ -32,7 +32,7 @@ class="d-flex flex-column justify-content-center"
|
|||||||
@else
|
@else
|
||||||
<div class="mb-2 mx-2">
|
<div class="mb-2 mx-2">
|
||||||
<label for="avatar" style="width: 100%;">
|
<label for="avatar" style="width: 100%;">
|
||||||
<img src="{{ auth()->user()->artists()->first()->avatar() }}" style="width: 100%; max-width: 100%;">
|
<img src="{{ auth()->user()->artists()->first()->avatar() }}" style="width: 100%; max-width: 350px;">
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-2 mx-2">
|
<div class="mb-2 mx-2">
|
||||||
|
42
site/resources/views/livewire/artist/header.blade.php
Normal file
42
site/resources/views/livewire/artist/header.blade.php
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<form wire:submit.prevent="save">
|
||||||
|
@if($header)
|
||||||
|
<div
|
||||||
|
class="d-flex flex-column justify-content-center"
|
||||||
|
wire:ignore
|
||||||
|
x-data="{
|
||||||
|
setUp() {
|
||||||
|
const cropper = new Cropper(document.getElementById('header'), {
|
||||||
|
aspectRatio: 1.46,
|
||||||
|
autoCropArea: 1,
|
||||||
|
viewMode: 1,
|
||||||
|
crop (event) {
|
||||||
|
@this.set('x', event.detail.x)
|
||||||
|
@this.set('y', event.detail.y)
|
||||||
|
@this.set('width', event.detail.width)
|
||||||
|
@this.set('height', event.detail.height)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
x-init="setUp"
|
||||||
|
>
|
||||||
|
<div class="d-flex justify-content-center text-center mt-4 mb-4">
|
||||||
|
<img id="header" src="{{ $header->temporaryUrl() }}" style="width: 100%; max-width: 270px; margin:5px auto;">
|
||||||
|
</div>
|
||||||
|
<div class="d-flex justify-content-end text-end mt-4 mb-4">
|
||||||
|
<button type="submit" class="btn btn-gradient btn-small">
|
||||||
|
<span>Save Profile Header</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@else
|
||||||
|
<div class="mb-2 mx-2">
|
||||||
|
<label for="header" style="width: 100%;">
|
||||||
|
<img src="{{ auth()->user()->artists()->first()->header() }}" style="width: 100%; max-width: 270px; margin:5px auto;">
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="mb-2 mx-2">
|
||||||
|
<input type="file" name="header" id="header" class="sr-only" wire:model="header">
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
</form>
|
@ -77,9 +77,6 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
@endif
|
@endif
|
||||||
@if (auth()->user())
|
|
||||||
<livewire:themeswitch />
|
|
||||||
@else
|
|
||||||
<li>
|
<li>
|
||||||
<label class="theme-switcher-label d-flex" for="theme-switcher">
|
<label class="theme-switcher-label d-flex" for="theme-switcher">
|
||||||
<input type="checkbox" class="theme-switcher" id="theme-switcher">
|
<input type="checkbox" class="theme-switcher" id="theme-switcher">
|
||||||
@ -89,7 +86,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</label>
|
</label>
|
||||||
</li>
|
</li>
|
||||||
@endif
|
|
||||||
<li class="setting-option mobile-menu-bar d-block d-xl-none">
|
<li class="setting-option mobile-menu-bar d-block d-xl-none">
|
||||||
<button class="hamburger-button">
|
<button class="hamburger-button">
|
||||||
<i class="ri-menu-2-fill"></i>
|
<i class="ri-menu-2-fill"></i>
|
||||||
@ -121,7 +117,19 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<nav>
|
<nav>
|
||||||
|
<ul class="mainmenu">
|
||||||
@include('partials/nav/main')
|
@include('partials/nav/main')
|
||||||
|
<li class="has-dropdown has-menu-child-item">
|
||||||
|
<a {!! request()->is(['podcasts', 'podcasts/*']) ? 'class="active"' : '' !!}>Podcasts</a>
|
||||||
|
<ul class="submenu">
|
||||||
|
@foreach ($navPodcasts as $cast)
|
||||||
|
<li>
|
||||||
|
<a href="/podcasts/{{ $cast->slug }}">{{ $cast->name }}</a>
|
||||||
|
</li>
|
||||||
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<a {!! request()->is(['artworks', 'artworks/*']) ? 'class="active"' : '' !!} href="/artworks">Submitted</a>
|
<a {!! request()->is(['artworks', 'artworks/*']) ? 'class="active"' : '' !!} href="/artworks">Submitted</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a {!! request()->is(['artists', 'artists/*']) ? 'class="active"' : '' !!} href="/artists">Artists</a>
|
<a {!! request()->is(['artists', 'artists/*', 'artist', 'artist/*', 'profile']) ? 'class="active"' : '' !!} href="/artists">Artists</a>
|
||||||
</li>
|
</li>
|
||||||
@if (auth()->user())
|
@if (auth()->user())
|
||||||
<li>
|
<li>
|
||||||
|
@ -27,6 +27,9 @@
|
|||||||
<div class="col-xl-4 col-lg-12 mb-4">
|
<div class="col-xl-4 col-lg-12 mb-4">
|
||||||
@include('profile.partials.update-avatar-form')
|
@include('profile.partials.update-avatar-form')
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-xl-4 col-lg-12 mb-4">
|
||||||
|
@include('profile.partials.update-header-form')
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<div class="single-author profile flex-stretch">
|
<div class="single-author profile flex-stretch">
|
||||||
<div class="thumb">
|
<div class="thumb">
|
||||||
<img src="{{ Vite::asset($artist->header ?? 'resources/img/artist-dark-banner-default.png') }}" alt="{{ $artist->name }}'s Cover Photo" />
|
<img src="{{ $artist->header() }}" alt="{{ $artist->name }}'s Cover Photo" />
|
||||||
</div>
|
</div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<a href="/artist/{{ $artist->slug }}"><img class="author-thumb avatar_img" src="{{ $artist->avatar() }}"
|
<a href="/artist/{{ $artist->slug }}"><img class="author-thumb avatar_img" src="{{ $artist->avatar() }}"
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
<div class="authbox">
|
<div class="authbox" style="min-height: 100%;">
|
||||||
<div class="row mt-4 gutter-2">
|
<div class="row mt-4 gutter-2">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="signin-content">
|
<div class="signin-content">
|
||||||
<div class="mb-6">
|
<div class="mb-6">
|
||||||
<h2 class="mb-2">{{ __('Update Artist Avatar') }}</h2>
|
<h3 class="mb-2">{{ __('Update Artist Avatar') }}</h3>
|
||||||
<p class="normal">{{ __('This avatar will be used on the artist gallery and artist profile page.') }}</p>
|
<p class="normal">{{ __('This avatar will be used on the artist gallery and artist profile page.') }}</p>
|
||||||
|
<p class="small">Be patient, it takes a moment to process.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
<div class="authbox" style="min-height: 100%;">
|
||||||
|
<div class="row mt-4 gutter-2">
|
||||||
|
<div class="col">
|
||||||
|
<div class="signin-content">
|
||||||
|
<div class="mb-6">
|
||||||
|
<h3 class="mb-2">{{ __('Update Profile Header') }}</h3>
|
||||||
|
<p class="normal">{{ __('This header is used in the artist listing and artist profile page.') }}</p>
|
||||||
|
<p class="small">Be patient, it takes a moment to process.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mt-0 gutter-2">
|
||||||
|
<div class="col">
|
||||||
|
<livewire:artist.header />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -1,9 +1,9 @@
|
|||||||
<div class="authbox">
|
<div class="authbox" style="min-height: 100%;">
|
||||||
<div class="row mt-4 gutter-2">
|
<div class="row mt-4 gutter-2">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="signin-content">
|
<div class="signin-content">
|
||||||
<div class="mb-6">
|
<div class="mb-6">
|
||||||
<h2 class="mb-2">{{ __('Update Password') }}</h2>
|
<h3 class="mb-2">{{ __('Update Password') }}</h3>
|
||||||
<p class="normal">{{ __('Ensure your account is using a long, random password to stay secure.') }}</p>
|
<p class="normal">{{ __('Ensure your account is using a long, random password to stay secure.') }}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
<div class="authbox">
|
<div class="authbox" style="min-height: 100%;">
|
||||||
<div class="row mt-4 gutter-2">
|
<div class="row mt-4 gutter-2">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="signin-content">
|
<div class="signin-content">
|
||||||
<div class="mb-6">
|
<div class="mb-6">
|
||||||
<h2 class="mb-2">{{ __('Update Login') }}</h2>
|
<h3 class="mb-2">{{ __('Update Login') }}</h3>
|
||||||
<p class="normal">{{ __("Update your account's username and email address. Note, your username may not be the same as your public artist profile.") }}</p>
|
<p class="normal">{{ __("Update your account's username and email address. Note, your username may not be the same as your public artist profile.") }}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user