App\Http\Controllers\ArtistsController::show PHP Method

show() public method

public show ( $id )
    public function show($id)
    {
        $artist = Artist::with('label')->findOrFail($id);
        $albums = $artist->albums()->where('visible', true)->with(['tracks' => function ($query) {
            $query->orderBy('display_order', 'ASC');
        }])->get();
        $tracks = $artist->tracks()->whereNull('album_id')->orderBy('display_order', 'ASC NULLS LAST')->get();
        $images = ['header_url' => $artist->header_url, 'cover_url' => $artist->cover_url];
        // should probably move services to a separate model if the number increases further
        $links = [];
        foreach (['soundcloud', 'twitter', 'facebook', 'bandcamp', 'patreon'] as $service) {
            if ($artist->{$service}) {
                $links[] = ['title' => ucwords($service), 'url' => $artist->{$service}, 'icon' => $service === 'patreon' ? "extra-social-{$service}" : $service, 'class' => $service];
            }
        }
        if ($artist->website) {
            $links[] = ['title' => trans('artist.links.site'), 'url' => $artist->website, 'icon' => 'globe', 'class' => 'website'];
        }
        return view('artists.show')->with('artist', $artist)->with('links', $links)->with('albums', json_collection($albums, new ArtistAlbumTransformer(), ['tracks']))->with('tracks', json_collection($tracks, new ArtistTrackTransformer()))->with('images', $images);
    }
ArtistsController