コード例 #1
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     //
     view()->composer('_recent', function ($view) {
         $data = Images::leftJoin('albums', 'images.album_id', '=', 'albums.id')->leftJoin('users', 'images.user_id', '=', 'users.id')->select('images.*', 'albums.name as albumname', 'users.name as username')->limit(4)->where("images.status", "=", 'Public')->orderBy('images.id', 'desc')->get();
         $view->with("recent", $data);
     });
     view()->composer('_album', function ($view) {
         $data = Album::leftJoin('album_types', 'albums.albumtype_id', '=', 'album_types.id')->select('albums.*', 'album_types.name as typename')->orderBy('albums.id', 'desc')->get();
         $view->with("albums", $data);
     });
 }
コード例 #2
0
 /**
  * Display the images list.
  *
  * @param  int  $type
  * @return \Illuminate\Http\Response
  */
 public function listimages($type = '')
 {
     //
     if (strtolower($type) == 'all') {
         //$data = Images::get();
         $data = Images::leftJoin('albums', 'images.album_id', '=', 'albums.id')->leftJoin('users', 'images.user_id', '=', 'users.id')->select('images.*', 'albums.name as albumname', 'users.name as username')->get();
         //dd($data);
         return view('image.list', ['albumtype' => $data])->with('type', ucfirst($type));
     } elseif (strtolower($type) == 'my') {
         $userDate = Auth::user();
         $data = Images::leftJoin('albums', 'images.album_id', '=', 'albums.id')->leftJoin('users', 'images.user_id', '=', 'users.id')->where('users.id', '=', $userDate->id)->select('images.*', 'albums.name as albumname', 'users.name as username')->get();
         return view('image.list', ['albumtype' => $data])->with('type', ucfirst($type));
     } else {
         return redirect('/dashboard')->withErrors("Invalid URL Entered");
     }
 }