fix: user can update bio info

This commit is contained in:
Paul Couture 2023-12-21 10:20:49 -06:00
parent ca34ab4b37
commit 173986da5e
8 changed files with 107 additions and 1 deletions

View File

@ -7,6 +7,9 @@
use App\Models\Podcast; use App\Models\Podcast;
use App\Models\Episode; use App\Models\Episode;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\Rule;
class ArtistController extends Controller class ArtistController extends Controller
{ {
@ -97,7 +100,28 @@ public function edit(Artist $artist)
*/ */
public function update(Request $request, Artist $artist) public function update(Request $request, Artist $artist)
{ {
// $user = auth()->user();
$artist = $user->artists->first();
$rules = [
'location' => ['string', 'max:255'],
'alby' => ['email'],
'website' => ['url'],
'nasocial' => ['starts_with:@'],
];
$validator = Validator::make($request->all(), $rules);
if ($validator->fails()) {
return back()
->withErrors($validator)
->withInput();
}
$artist->location = $request->location;
$artist->alby = $request->alby;
$artist->website = $request->website;
$artist->nasocial = $request->nasocial;
if ($artist->isDirty()) {
$artist->save();
}
return redirect('/profile');
} }
/** /**

View File

@ -29,6 +29,8 @@ class Artist extends Model
'avatar', 'avatar',
'header', 'header',
'location', 'location',
'alby',
'naasocial',
'website', 'website',
'bio', 'bio',
'created_at', 'created_at',

View File

@ -32,6 +32,8 @@ public function definition()
'avatar' => fake()->imageUrl(512, 512), 'avatar' => fake()->imageUrl(512, 512),
'header' => fake()->imageUrl(270, 185), 'header' => fake()->imageUrl(270, 185),
'location' => fake()->city() . ', ' . fake()->state(), 'location' => fake()->city() . ', ' . fake()->state(),
'alby' => null,
'naasocial' => null,
'website' => rand(0, 1) ? fake()->url : null, 'website' => rand(0, 1) ? fake()->url : null,
'bio' => fake()->paragraphs(rand(1, 3), true), 'bio' => fake()->paragraphs(rand(1, 3), true),
]; ];

View File

@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('artists', function (Blueprint $table) {
$table->string('alby')->nullable()->after('location');
$table->string('nasocial')->nullable()->after('location');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('artists', function (Blueprint $table) {
$table->dropColumn('alby');
$table->dropColumn('nasocial');
});
}
};

View File

@ -30,6 +30,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-header-form') @include('profile.partials.update-header-form')
</div> </div>
<div class="col-xl-4 col-lg-12 mb-4">
@include('profile.partials.update-location-form')
</div>
</div> </div>
</div> </div>
</section> </section>

View File

@ -0,0 +1,42 @@
<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 Details') }}</h3>
<p class="normal">{{ __("Update the Details shown on your profile.") }}</p>
</div>
</div>
</div>
</div>
<div class="row mt-0 gutter-2">
<div class="col">
<form method="post" action="/update-profile">
@csrf
<div>
<x-input-label for="location" :value="__('Location')" />
<x-text-input id="location" name="location" type="text" class="mt-1 block w-full" :value="old('location', $user->artists->first()->location)" required autocomplete="location" />
<x-input-error class="mt-2" :messages="$errors->get('location')" />
</div>
<div class="mt-1">
<x-input-label for="alby" :value="__('Value for Value Alby Address⚡')" />
<x-text-input id="alby" name="alby" type="text" class="mt-1 block w-full" :value="old('alby', $user->artists->first()->alby)" required autocomplete="alby" />
<x-input-error class="mt-2" :messages="$errors->get('alby')" />
</div>
<div class="mt-1">
<x-input-label for="nasocial" :value="__('No Agenda Social Account')" />
<x-text-input id="nasocial" name="nasocial" type="text" class="mt-1 block w-full" :value="old('nasocial', $user->artists->first()->nasocial)" required autocomplete="naasocial" />
<x-input-error class="mt-2" :messages="$errors->get('nasocial')" />
</div>
<div class="mt-1">
<x-input-label for="website" :value="__('Website')" />
<x-text-input id="website" name="website" type="text" class="mt-1 block w-full" :value="old('website', $user->artists->first()->website)" required autocomplete="naasocial" />
<x-input-error class="mt-2" :messages="$errors->get('website')" />
</div>
<div class="d-flex justify-content-end mt-4 mb-4 text-end">
<x-primary-button class="ml-3 btn btn-gradient"><span>Update Details</span></x-primary-button>
</div>
</form>
</div>
</div>
</div>

View File

@ -42,6 +42,7 @@
Route::get('/create-artwork', [ArtworkController::class, 'create']); Route::get('/create-artwork', [ArtworkController::class, 'create']);
Route::post('/create-artwork', [ArtworkController::class, 'store']); Route::post('/create-artwork', [ArtworkController::class, 'store']);
Route::get('/update-avatar', [ArtistController::class, 'avatar'])->name('avatar.edit'); Route::get('/update-avatar', [ArtistController::class, 'avatar'])->name('avatar.edit');
Route::post('/update-profile', [ArtistController::class, 'update'])->name('profile-details.edit');
}); });
Route::get('/counter', Counter::class); Route::get('/counter', Counter::class);

2
site/storage/debugbar/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore