114 lines
		
	
	
		
			2.8 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			114 lines
		
	
	
		
			2.8 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace App\Http\Controllers;
 | |
| 
 | |
| use App\Models\Artist;
 | |
| use App\Models\Artwork;
 | |
| use App\Models\Podcast;
 | |
| use App\Models\Episode;
 | |
| use Illuminate\Http\Request;
 | |
| 
 | |
| class ArtistController extends Controller
 | |
| {
 | |
|     /**
 | |
|      * Display a listing of the resource.
 | |
|      *
 | |
|      * @return \Illuminate\Http\Response
 | |
|      */
 | |
|     public function index()
 | |
|     {
 | |
|         $user = auth()->user();
 | |
|         $artists = Artist::whereHas('artworks')
 | |
|             ->withCount('artworks')
 | |
|             ->orderBy('artworks_count', 'desc')
 | |
|             ->paginate(100);
 | |
|         $podcasts = Podcast::where('published', true)->with('episodes')->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)
 | |
|     {
 | |
|         //
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * Remove the specified resource from storage.
 | |
|      *
 | |
|      * @param  \App\Models\Artist  $artist
 | |
|      * @return \Illuminate\Http\Response
 | |
|      */
 | |
|     public function destroy(Artist $artist)
 | |
|     {
 | |
|         //
 | |
|     }
 | |
| }
 |