Пример #1
0
 public function nav()
 {
     $website_to_project = array();
     $websites = Website::get();
     if ($websites) {
         foreach ($websites as $key => $val) {
             $websites_array[$val['websites_id']] = $val['websites_name'];
         }
     }
     $projects = Project::get();
     if ($projects) {
         foreach ($projects as $key => $val) {
             $projects_array[$val['projects_id']] = $val['projects_name'];
         }
     }
     $posts = Post::select('website', 'project')->orderby("website", "asc")->orderby("project", "asc")->get();
     if ($posts) {
         foreach ($posts as $key => $val) {
             $website_to_project[$val['website']]['websites_name'] = $websites_array[$val['website']];
             $website_to_project[$val['website']]['projects_name'][$val['project']] = $projects_array[$val['project']];
         }
     }
     return response()->json($website_to_project);
 }