/**
  * Show the Project view page. (BY ANDREI)
  *
  * @return project_tbl data, date, amount
  */
 public function show($slug)
 {
     // fetch data according to slug
     $project = $slug;
     $logos = Sponsor::where('active', 1)->get();
     // find the Users Favourites and catch them
     $favourites = Favourite::all()->where('user_id', Session::get('userId'))->where('project_id', $project->id);
     //dd($favourites);
     // convert DB date into european date format
     $finish_date = date("d-m-Y", strtotime($project->completed_on));
     // convert DB amounts into european currency format
     $amount_raised = number_format($project->amount_raised, 2, ',', '.');
     $target_amount = number_format($project->target_amount, 2, ',', '.');
     $galleryImages = \App\Image::where('project_id', $project->id)->get();
     return view('pages.projectpage', compact('project', 'logos', 'finish_date', 'amount_raised', 'target_amount', 'galleryImages', 'favourites'));
 }
 /**
  * Display the specified resource.
  *
  * @param $username
  * @internal param int $id
  * @return Response
  */
 public function show($username)
 {
     try {
         $user = Auth::user()->with('projects')->where('user_name', $username)->firstOrFail();
     } catch (ModelNotFoundException $e) {
         return Redirect::home();
     }
     // Take the Administrator to the admin panel.
     if ($user->id == '2') {
         return redirect('admin');
     }
     $contributions = Pledge::where('user_id', '=', $user->id)->get();
     $favourites = Favourite::with('project')->where('user_id', '=', $user->id)->get();
     // if it's a regular user, redirect to user's dashboard
     return view('userpanel.index', compact('user', 'contributions', 'favourites'));
 }