/**
  * TODO  Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $album = Album::with('songs')->find($id);
     /**
      *
      * display album name
      */
     echo '<strong>' . 'One to Many relationship' . '</strong>' . '<br>' . '<br>';
     echo 'Album Name:' . '<li>' . $album->name;
     echo '<br>';
     /**
      * Grab the songs for
      */
     echo '<br>';
     echo 'songs' . '<br>';
     foreach ($album->songs as $key => $value) {
         /**
          * display songs for each album
          */
         echo '<br>' . '<li>' . $value->name;
     }
     /**
      * Many to Many relationship
      * TODO Display album listeners
      */
     echo '<br>';
     echo '<br>';
     echo '<br>';
     echo '<strong>' . 'Many to Many relationship' . '</strong>' . '<br>';
     echo '<br>' . 'Album listeners' . '<br>';
     $album = Album::find($id);
     foreach ($album->listeners as $listeners) {
         echo '<li>' . $listeners->name;
     }
 }
Esempio n. 2
0
 public function getAlbumsWithPaginate(Request $request)
 {
     $perPage = $request->get('num');
     if (!is_numeric($perPage) || $perPage < 1 || $perPage > 30) {
         $perPage = 15;
     }
     $albums = Album::with(['musics' => function ($query) {
         $query->orderBy('track', 'asc');
     }])->orderBy('id', 'desc')->paginate($perPage);
     return $this->buildResponse(trans('api.album.paginate.success'), Tools::toArray($albums));
 }
 public function getAlbum($id)
 {
     $album = Album::with('Photos')->find($id);
     return View::make('album')->with('album', $album);
 }
 public function showAlbum($id)
 {
     $album = Album::with('Photos')->find($id);
     return view('front.gallery.images')->with('album', $album);
 }