Example #1
0
 public function zones()
 {
     //return all zones for role admin
     if ($this->role == "admin") {
         return Zone::all();
     }
     //else return user zones
     return $this->belongsToMany('App\\Zone', 'user_zone', 'user', 'zone')->get();
 }
 public function index()
 {
     // Grab all of our zones.  If there are none, import the list from our cloud provider.
     $zones = Zone::all();
     if ($zones->count() == 0) {
         unset($zones);
         // Store the zones in the database, defaulting them to disabled.
         $providerZones = app('Cloudstack\\CloudStackClient')->listZones();
         foreach ($providerZones as $providerZone) {
             Zone::create(['zone_id' => $providerZone->id, 'name' => $providerZone->name, 'status' => 'Disabled']);
         }
         $zones = Zone::all();
     }
     return view('admin.zone.index')->with(compact('zones'));
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $page = "Tous les Quartiers";
     $zones = Zone::all();
     return view('admin.zone.index', compact('zones', 'page'));
 }
Example #4
0
 /**
  *Handle post ajax request to /chartdata
  *
  * @param Request $request
  * @return \Illuminate\Http\Response
  */
 public function chartdata(Request $request)
 {
     if ($request->ajax()) {
         $zonecounter = array();
         $citycounter = array();
         $statecounter = array();
         $zones = Zone::all();
         foreach ($zones as $zone) {
             $count = $zone->repairshop()->count();
             $city = $zone->city;
             $state = $city->state;
             $zonecounter[$zone->zone] = $count;
             if (isset($citycounter[$city->city])) {
                 $citycounter[$city->city] += $count;
             } else {
                 $citycounter[$city->city] = $count;
             }
             if (isset($statecounter[$state->state])) {
                 $statecounter[$state->state] += $count;
             } else {
                 $statecounter[$state->state] = $count;
             }
         }
         return Response::json(["output" => array("state" => $statecounter, "city" => $citycounter, "zone" => $zonecounter)]);
     }
 }