user(); $artists = Artist::whereHas('artworks') ->withCount('artworks') ->orderBy('artworks_count', 'desc') ->paginate(100); $podcasts = Podcast::where('published', true)->get(); return view('profile.artists', [ 'user' => $user, 'pageTitle' => 'Artists', 'podcasts' => $podcasts, 'artists' => $artists, ]); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { // } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { // } /** * Display the specified resource. * * @param \App\Models\Artist $artist * @return \Illuminate\Http\Response */ public function show(Request $request, $slug) { $user = auth()->user(); $artist = Artist::where('slug', $slug) ->firstOrFail(); $artworks = Artwork::where('artist_id', $artist->id) ->with('episode') ->with('podcast') ->orderBy('artworks.created_at', 'desc') ->paginate($perPage = 92, $columns = ['*'], $pageName = 'artworks'); $podcasts = Podcast::where('published', true)->with('episodes')->get(); return view('profile.artist', [ 'user' => $user, 'artist' => $artist, 'artworks' => $artworks, 'podcasts' => $podcasts, ]); } /** * Show the form for editing the specified resource. * * @param \App\Models\Artist $artist * @return \Illuminate\Http\Response */ public function edit(Artist $artist) { // } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param \App\Models\Artist $artist * @return \Illuminate\Http\Response */ 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'); } /** * Remove the specified resource from storage. * * @param \App\Models\Artist $artist * @return \Illuminate\Http\Response */ public function destroy(Artist $artist) { // } }