Ejemplo n.º 1
0
 public function index($group)
 {
     if (Auth::guest()) {
         return view('welcome');
     } elseif (Auth::user()->level < 1) {
         return view('welcome');
     }
     //Por defeito, quando não ha parametros no url, angola vai a 1 e africa a 0
     $ang = Input::get('angola');
     $afr = Input::get('africa');
     $angola = 1;
     $africa = 0;
     $order = "All";
     if (Input::get('order')) {
         $order = Input::get('order');
     }
     if ($ang != NULL and $ang != "") {
         $angola = Input::get('angola');
     }
     if ($afr != NULL and $afr != "") {
         $africa = Input::get('africa');
     }
     $orderlist = MammalTaxonomy::select(DB::raw('DISTINCT "order"'))->get();
     //Adiciona o valor All na lista
     $orderlist->add(["order" => "All"]);
     $species_list = DB::table($group . "_taxonomy");
     if ($order != "All" and $order != "" and $order != NULL) {
         $species_list = $species_list->where('order', $order);
     }
     if ($angola == 1) {
         $species_list = $species_list->where('angola', 1);
     }
     if ($africa == 1) {
         $species_list = $species_list->where('africa', 1);
     }
     $species_list = $species_list->paginate(100);
     return view('taxonomy.list', compact('species_list', 'group', 'order', 'orderlist', 'angola', 'africa'));
 }