/**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $images = Picture::where('user_id', '=', Auth::user()->id)->where('isDish', '=', false)->orderBy('id', 'desc')->take(5)->get();
     $profile = User::find(Auth::user()->id);
     $favoriteDish = explode(';', $profile->favoriteDish);
     $time = explode("-", $profile->dateOfBirth);
     $dt = Carbon::createFromDate($time[0], $time[1], $time[2], 'Europe/Brussels');
     $now = Carbon::today();
     $age = $now->diffInYears($dt);
     $profile->age = $age;
     foreach ($favoriteDish as $key => $value) {
         if ($value == "") {
             unset($favoriteDish[$key]);
         }
     }
     $profile->favoriteDishArray = $favoriteDish;
     $friends = User::where('id', '=', Auth::user()->id)->first()->friends()->get();
     $friendRequests = Friend::where('friend_id', '=', Auth::user()->id)->where('accepted', '=', false)->get();
     $mayLike = array();
     foreach ($profile->tastes as $taste) {
         $othersTaste = $taste->users()->where('user_id', '<>', Auth::user()->id)->where('taste_id', $taste->id)->get();
         foreach ($othersTaste as $user) {
             $mayLike[] = $user->id;
         }
     }
     //count how many times an id apears in array
     $CountMayLikes = array_count_values($mayLike);
     //sort from high to low
     arsort($CountMayLikes);
     //var_dump($CountMayLikes);
     $sortedArray = [];
     foreach ($CountMayLikes as $id => $value) {
         $sortedArray[] = $id;
     }
     //var_dump($sortedArray);
     //give te first 10z
     $pYML = array_slice($sortedArray, 0, 10);
     $people = User::whereIn('id', $pYML)->select('id', 'name', 'surname', 'country', 'city', 'dateOfBirth')->get();
     foreach ($people as $person) {
         // var_dump($person->id);
         $picture_url = Picture::where('user_id', $person->id)->select('picture_url')->first();
         // echo '<pre>';
         // var_dump($picture_url['picture_url']);
         $person->picture_url = $picture_url['picture_url'];
     }
     $smaken = Taste::select('id', 'tastes')->get();
     $tasts = array();
     foreach ($smaken as $smaak) {
         $tasts[$smaak->id] = $smaak->tastes;
     }
     $data = ['profile' => $profile, 'friends' => $friends, 'friendRequests' => $friendRequests, 'images' => $images, 'tasts' => $tasts, 'peoples' => $people];
     return View('dashboard')->with($data);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $tast = new Taste();
     $tast->tastes = "bitter";
     $tast->save();
     $tast1 = new Taste();
     $tast1->tastes = "zoet";
     $tast1->save();
     $tast2 = new Taste();
     $tast2->tastes = "zout";
     $tast2->save();
     $tast3 = new Taste();
     $tast3->tastes = "zuur";
     $tast3->save();
     $tast4 = new Taste();
     $tast4->tastes = "umami";
     $tast4->save();
     $tast5 = new Taste();
     $tast5->tastes = "chinees";
     $tast5->save();
     $tast5 = new Taste();
     $tast5->tastes = "italiaans";
     $tast5->save();
     $tast5 = new Taste();
     $tast5->tastes = "italiaans";
     $tast5->save();
     $tast5 = new Taste();
     $tast5->tastes = "vegitarisch";
     $tast5->save();
     $tast5 = new Taste();
     $tast5->tastes = "boerenkost";
     $tast5->save();
     $tast5 = new Taste();
     $tast5->tastes = "spaans";
     $tast5->save();
 }