diff --git a/site/app/Http/Controllers/ArtistController.php b/site/app/Http/Controllers/ArtistController.php index 24786f5..9460daa 100644 --- a/site/app/Http/Controllers/ArtistController.php +++ b/site/app/Http/Controllers/ArtistController.php @@ -7,6 +7,9 @@ use App\Models\Podcast; use App\Models\Episode; use Illuminate\Http\Request; +use Illuminate\Http\RedirectResponse; +use Illuminate\Support\Facades\Validator; +use Illuminate\Validation\Rule; class ArtistController extends Controller { @@ -97,7 +100,28 @@ public function edit(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'); } /** diff --git a/site/app/Models/Artist.php b/site/app/Models/Artist.php index 15d7634..64bab69 100644 --- a/site/app/Models/Artist.php +++ b/site/app/Models/Artist.php @@ -29,6 +29,8 @@ class Artist extends Model 'avatar', 'header', 'location', + 'alby', + 'naasocial', 'website', 'bio', 'created_at', diff --git a/site/database/factories/ArtistFactory.php b/site/database/factories/ArtistFactory.php index 2b033fc..293dbf6 100644 --- a/site/database/factories/ArtistFactory.php +++ b/site/database/factories/ArtistFactory.php @@ -32,6 +32,8 @@ public function definition() 'avatar' => fake()->imageUrl(512, 512), 'header' => fake()->imageUrl(270, 185), 'location' => fake()->city() . ', ' . fake()->state(), + 'alby' => null, + 'naasocial' => null, 'website' => rand(0, 1) ? fake()->url : null, 'bio' => fake()->paragraphs(rand(1, 3), true), ]; diff --git a/site/database/migrations/2023_12_21_150617_add_alby_to_artists.php b/site/database/migrations/2023_12_21_150617_add_alby_to_artists.php new file mode 100644 index 0000000..56cf64e --- /dev/null +++ b/site/database/migrations/2023_12_21_150617_add_alby_to_artists.php @@ -0,0 +1,30 @@ +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'); + }); + } +}; diff --git a/site/resources/views/profile/edit.blade.php b/site/resources/views/profile/edit.blade.php index 27a62f0..bbca157 100644 --- a/site/resources/views/profile/edit.blade.php +++ b/site/resources/views/profile/edit.blade.php @@ -30,6 +30,9 @@
{{ __("Update the Details shown on your profile.") }}
+