/**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     // Check if a user is logged in.
     if (!($user = $request->user())) {
         // If not, continue the request.
         return $next($request);
     }
     // Get the current route.
     $route = $request->route();
     // Get the current route actions.
     $actions = $route->getAction();
     // Check if we have any permissions to check.
     if (!($permissions = isset($actions['permissons']) ? $actions['permissons'] : null)) {
         // No permissions to check, allow access.
         return $next($request);
     }
     // Fetch all of the users permissions.
     $userPermissions = array_fetch($user->permissions()->whereIn('slug', (array) $permissions)->get()->toArray(), 'slug');
     // Ensure that the required permissions are an array.
     $permissions = (array) $permissions;
     if (isset($actions['permissions_require_all'])) {
         // If the user has EVERY permission required.
         if (count($permissions) == count($userPermissions)) {
             // Allow the request.
             return $next($request);
         }
     } else {
         if (count($userPermissions) > 0) {
             // Allow the request.
             return $next($request);
         }
     }
     // Abort the request if we reach here.
     return abort(401);
 }
Example #2
0
 protected function getAllTabsFromAllRoles()
 {
     $tabs = $this->roles->load('tabs')->fetch('tabs')->toArray();
     return array_map('strtolower', array_unique(array_flatten(array_map(function ($tab) {
         return array_fetch($tab, 'tab_slug');
     }, tabs))));
 }
 public function handle($request, Closure $next)
 {
     if (!($user = $request->user())) {
         return $next($request);
     }
     $route = $request->route();
     $actions = $route->getAction();
     if (!($permissions = isset($action['permission_title']) ? $actions['permission_title'] : null)) {
         return $next($request);
     }
     $userPermissions = array_fetch($user->permissions()->whereIn('slug', (array) $permissions)->get()->toArray(), 'slug');
     $permissions = (array) $permissions;
     if (isset($actions['permissions_require_all'])) {
         // If user has EVERY permission required.
         if (count($permissions) == count($userPermissions)) {
             // Access is granted.
             return $next($request);
         }
     } else {
         // If the user has the permission.
         if (count($userPermissions) >= 1) {
             // Access is granted and the rest of the permissions are ignored.
             return $next($request);
         }
     }
     return abort(401);
 }
Example #4
0
 public function links()
 {
     $params = [];
     $list = [];
     $extras = [];
     $new_list_length = null;
     if (is_array(last($this->route_params))) {
         $extras = array_pop($this->route_params);
     }
     $append_plain = $this->getPlainTextExtras($extras, 'append_plain', $this->items);
     $prepend_plain = $this->getPlainTextExtras($extras, 'prepend_plain', $this->items);
     foreach ($this->route_params as $param) {
         $params[] = $this->collectKeys($this->items, $param)->toArray();
     }
     $items = $this->collectKeys($this->items, $this->key);
     if (array_key_exists('truncate', $extras)) {
         $this->setCharLimit($extras['truncate']);
         $new_list_length = $this->getTruncatedList($items);
         $this->setCharLimit(null);
     }
     foreach ($items as $key => $item) {
         $str = '';
         if ($str_prepend = $this->getPlainTextReplaced($extras, 'prepend_plain', $prepend_plain, $key)) {
             $str .= $str_prepend;
         }
         $str .= '<a href="' . route($this->route, array_fetch($params, $key)) . '">';
         $str .= $item . '</a>';
         if ($str_append = $this->getPlainTextReplaced($extras, 'append_plain', $append_plain, $key)) {
             $str .= $str_append;
         }
         $list[] = $str;
     }
     return $this->listize($list, $new_list_length);
 }
Example #5
0
 /**
  * Get all access module from all permissions of all roles.
  *
  * @return Array of permission slugs
  */
 public function hasAccess()
 {
     $permissions = $this->roles->load('permissions')->fetch('permissions')->toArray();
     return array_map('strtolower', array_unique(array_flatten(array_map(function ($permission) {
         return array_fetch($permission, 'permission_slug');
     }, $permissions))));
 }
Example #6
0
 public function makeUser($t)
 {
     $assign = array();
     $roles = array_fetch(\App\Role::all()->toArray(), 'name');
     $assign[] = $this->getIdInArray($roles, $t);
     $this->roles->attach($assign);
 }
Example #7
0
 /**
  * Get all permission slugs from all permissions of all roles
  *
  * @return Array of permission slugs
  */
 protected function getAllPermissionsFromAllRoles()
 {
     $permissions = $this->roles->load('permissions')->fetch('permissions')->toArray();
     return array_map('strtolower', array_unique(array_flatten(array_map(function ($permission) {
         return array_fetch($permission, 'permission_slug');
     }, $permissions))));
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     // Check if a user is logged in.
     if (!($user = $request->user())) {
         return $next($request);
     }
     $route = $request->route();
     // Get the current route actions.
     $actions = $route->getAction();
     // Check if we have any permissions to check the user has.
     if (!($permissions = isset($actions['permissions']) ? $actions['permissions'] : null)) {
         // No permissions to check, allow access.
         return $next($request);
     }
     // Fetch all of the matching user permissions.
     $userPermissions = array_fetch($user->permissions()->whereIn('slug', (array) $permissions)->get()->toArray(), 'slug');
     // Turn the permissions we require into an array.
     $permissions = (array) $permissions;
     // Check if we require all permissions, or just one.
     if (isset($actions['permissions_require_all'])) {
         // If user has EVERY permission required.
         if (count($permissions) == count($userPermissions)) {
             // Access is granted.
             return $next($request);
         }
     } else {
         // If the user has the permission.
         if (count($userPermissions) >= 1) {
             // Access is granted and the rest of the permissions are ignored.
             return $next($request);
         }
     }
     // If we reach this far, the user does not have the required permissions.
     return Redirect::back();
 }
Example #9
0
 public static function disponible($horarios, $asignatura_id, $ciclo_id, $horas)
 {
     $ciclo = Ciclo::find($ciclo_id);
     $asignatura = Asignatura::find($asignatura_id);
     $profesores_disponibles = self::whereHas('clases', function ($q) use($ciclo_id, $horarios) {
         $q->whereHas('grupo', function ($q) use($ciclo_id) {
             $q->where('ciclo_id', '=', $ciclo_id);
         })->whereIn('horario_id', array_fetch($horarios->toArray(), 'id'));
     }, '<=', $horarios->count() - $horas)->whereHas('asignaturas', function ($q) use($asignatura) {
         $q->where('asignatura_id', '=', $asignatura->id);
     })->get();
     if ($profesores_disponibles->count() > 0) {
         return $profesores_disponibles->random();
     }
     $profesores_capacitables = Profesor::whereHas('clases', function ($q) use($ciclo_id, $horarios) {
         $q->whereHas('grupo', function ($q) use($ciclo_id) {
             $q->where('ciclo_id', '=', $ciclo_id);
         })->whereIn('horario_id', array_fetch($horarios->toArray(), 'id'));
     }, '<=', $horarios->count() - $horas)->whereDoesntHave('asignaturas', function ($q) use($asignatura) {
         $q->where('asignatura_id', '=', $asignatura->id);
     })->has('asignaturas', '<', 10)->get();
     if ($profesores_capacitables->count() > 0) {
         $profesor = $profesores_capacitables->random();
         $profesor->asignaturas()->attach($asignatura->id);
         return $profesor;
     }
     $profesor = self::crearProfesor();
     $profesor->asignaturas()->attach($asignatura->id);
     return $profesor;
 }
Example #10
0
 public function avanzarCiclo($ciclo_id)
 {
     $carrera = $this->carrera;
     $nombre = $carrera->clave . ' ' . ($this->cuatrimestre + 1) . substr($this->nombre, 5, 2);
     $nuevo_grupo = Grupo::create(array('nombre' => $nombre, 'carrera_id' => $carrera->id, 'ciclo_id' => $ciclo_id, 'cuatrimestre' => $this->cuatrimestre + 1));
     $nuevo_grupo->alumnos()->attach(array_fetch($this->alumnos->toArray(), 'id'));
     return $nuevo_grupo;
 }
Example #11
0
 /**
  * Get category list by id
  *
  * @author Hein Zaw Htet
  **/
 public function getCategoryListById($id)
 {
     // $model = $this->model->find($id);
     // dd($model->categories()->id);
     $model = $this->model->find($id);
     $list = $model->categories->toArray();
     return array_fetch($list, 'id');
 }
Example #12
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $this->info('Alle records aanvullen met gegevens welke ontbreken vanuit CSV-bestand');
     $aantal = true;
     while ($aantal != 0) {
         $rij = Data::select('id')->where('temp', '!=', 2)->take(300)->get();
         $aantal = $rij->count();
         if ($aantal > 0) {
             foreach ($rij as $ro) {
                 $r = Data::find($ro->id);
                 $r->temp = 2;
                 $r->save();
             }
         }
         $this->info($aantal);
     }
     $this->info('\'region_of_destination\' fixen...');
     $regionLeeg = Data::select('city_of_destination', 'region_of_destination')->where('region_of_destination', '')->groupBy('city_of_destination')->get();
     if ($regionLeeg->count() > 0) {
         $city = Data::select('city_of_destination', 'region_of_destination')->where('region_of_destination', '!=', '')->whereIn('city_of_destination', array_fetch($regionLeeg->toArray(), 'city_of_destination'))->groupBy('city_of_destination')->get();
         foreach ($city->toArray() as $row) {
             Data::where('city_of_destination', $row['city_of_destination'])->where('region_of_destination', '')->update(array('region_of_destination' => $row['region_of_destination'], 'slug_region_of_destination' => Str::slug($row['region_of_destination'])));
         }
     }
     /**
      * Zijn er na bovenstaande actie nog steeds regels over zonder 'region_of_destination' dan verwijderen
      */
     $rowsStillNotOK = $regionLeeg2 = Data::where('region_of_destination', '')->delete();
     if ($rowsStillNotOK > 0) {
         $this->info('\'region_of_destination\' verwijderd: ' . $rowsStillNotOK . ' accommodaties');
     }
     $this->info('\'region_of_destination\' fixen... DONE');
     /**
      * Empty slug fixing
      */
     /*$this->info('\'slug_region_of_destination\' fixen...');
     
     		$slugToFill = Data::select('id', 'region_of_destination', 'slug_region_of_destination')
     			->where('region_of_destination', '!=', '')
     			->where('slug_region_of_destination', '')
     			->get();
     
     		if ($slugToFill->count() > 0)
     		{
     			foreach ($slugToFill->toArray() as $row)
     			{
     				Data::where('id', $row['id'])->update(
     					array(
     						'slug_region_of_destination' => \Str::slug($row['region_of_destination'])
     					)
     				);
     			}
     		}
     		$this->info('\'slug_region_of_destination\' fixen... DONE');*/
     $this->call('cache:clear');
     return $this->info('Done');
 }
Example #13
0
 public function isAllowedUser($user_id)
 {
     $user = User::where('id', '=', $user_id)->first();
     foreach ($this->roles as $role) {
         if (in_array($role->name, array_fetch($user->roles->toArray(), 'name'))) {
             return true;
         }
     }
     return false;
 }
Example #14
0
 /**
  * [getDataById description]
  * @param  integer 	$id 	policy id
  * @return array 	$datas  condition name information and count
  */
 public function getDataById($id)
 {
     $cond = ConditionPolicy::where('policy_id', '=', $id)->get(array('cond_id'));
     $cond_id = array_fetch($cond->toArray(), 'cond_id');
     $rs = DB::table('condition')->whereIn('id', $cond_id)->get(array('cond_name'));
     $datas['count'] = count($rs);
     $datas['data'] = $rs;
     $datas['id'] = $cond_id;
     return $datas;
 }
Example #15
0
 /**
  * [getDataById description]
  * @param  integer 	$id 	policy id
  * @return array 	$datas  role name information and count
  */
 public function getDataById($id)
 {
     $role = RolePolicy::where('policy_id', '=', $id)->get(array('role_id'));
     $role_id = array_fetch($role->toArray(), 'role_id');
     $rs = DB::table('roles')->whereIn('id', $role_id)->get(array('role_name'));
     $datas['count'] = count($rs);
     $datas['data'] = $rs;
     $datas['id'] = $role_id;
     return $datas;
 }
Example #16
0
 /**
  * [getDataById description]
  * @param  integer 	$id 	policy id
  * @return array 	$datas  purpose name information and count
  */
 public function getDataById($id)
 {
     $purp = PurposePolicy::where('policy_id', '=', $id)->get(array('purp_id'));
     $purp_id = array_fetch($purp->toArray(), 'purp_id');
     $rs = DB::table('purpose')->whereIn('id', $purp_id)->get(array('purp_name'));
     $datas['count'] = count($rs);
     $datas['data'] = $rs;
     $datas['id'] = $purp_id;
     return $datas;
 }
Example #17
0
 /**
  * 视图编辑数据
  * @param  [type] $id [description]
  * @return [type]     [description]
  */
 public function getForEdit($id)
 {
     $roleRow = $this->find($id);
     if (!$roleRow) {
         return false;
     }
     $navigationRows = array_fetch($roleRow->navigation->toArray(), 'id');
     $permissionRows = array_fetch($roleRow->permissions->toArray(), 'id');
     return ['navigationRows' => $navigationRows, 'permissionRows' => $permissionRows, 'roleRow' => $roleRow->toArray()];
 }
Example #18
0
 /**
  * [getDataById description]
  * @param  integer 	$id 	policy id
  * @return array 	$datas  obligation name information and count
  */
 public function getDataById($id)
 {
     $obl = ObligationPolicy::where('policy_id', '=', $id)->get(array('obl_id'));
     $obl_id = array_fetch($obl->toArray(), 'obl_id');
     $rs = DB::table('obligation')->whereIn('id', $obl_id)->get(array('obl_name'));
     $datas['count'] = count($rs);
     $datas['data'] = $rs;
     $datas['id'] = $obl_id;
     return $datas;
 }
Example #19
0
 public function timesOverSpeed($speedLimit)
 {
     $speeds = array_fetch($this->array_values(), 'speed');
     rsort($speeds);
     $times = 0;
     foreach ($speeds as $speed) {
         if ($speed >= $speedLimit) {
             $times++;
         }
     }
     return $times;
 }
Example #20
0
 /**
  * [getDataById retrive by policy id]
  * @param  integer 	$id 	policy id
  * @return array 	$datas  data name information and count
  */
 public function getDataById($id)
 {
     $data = DataPolicy::where('policy_id', '=', $id)->get(array('data_id'));
     $data_id = array_fetch($data->toArray(), 'data_id');
     $rs['name'] = DB::table('data')->whereIn('id', $data_id)->get(array('data_name'));
     $datas['count'] = count($rs);
     // count of data name
     $datas['data'] = $rs['name'];
     // array of data name
     $datas['id'] = $data_id;
     //array of data id
     return $datas;
 }
Example #21
0
 /**
  * Search AD for Users
  *
  * @param $query
  * @return array
  */
 public function searchUsers($query)
 {
     $response = $this->client->get("/user/search/{$query}*");
     $users = array_fetch($response->json()['data'], 'users');
     $return = [];
     // Transform to parsable array of user objects
     foreach ($users[0] as $ad_account => $display_name) {
         $user['ad_account'] = $ad_account;
         $user['display_name'] = $display_name;
         array_push($return, $user);
     }
     return $return;
 }
 public function get($id = null)
 {
     $search = Input::get('search');
     if (!is_null($search)) {
         $suppliers = Supplier::withTrashed()->where('name', 'like', '%' . $search . '%')->orWhere('ruc', 'like', '%' . $search . '%')->orderBy('name')->paginate(15);
     } else {
         $suppliers = Supplier::withTrashed()->orderBy('name')->paginate(15);
     }
     $selectedSupplier = self::__checkExistence($id);
     if (!$selectedSupplier) {
         $selectedSupplier = new Supplier();
     }
     $allProducts = Product::orderBy('name')->get()->lists('name', 'id');
     $selectedSupplierProducts = $selectedSupplier->products()->orderBy('name')->get()->toArray();
     return View::make('suppliers.main')->with('id', $id)->with('allProducts', $allProducts)->with('selectedSupplierProducts', array_fetch($selectedSupplierProducts, 'id'))->with('selectedSupplier', $selectedSupplier)->with('search', $search)->with('suppliers', $suppliers);
 }
Example #23
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     \Log::info('Fetch tweets');
     $client = new Client('https://api.twitter.com/1.1/');
     $auth = new Oauth(['consumer_key' => env('TWITTER_CONSUMER_KEY'), 'consumer_secret' => env('TWITTER_CONSUMER_SECRET'), 'token' => env('TWITTER_ACCESS_TOKEN'), 'token_secret' => env('TWITTER_ACCESS_TOKEN_SECRET')]);
     $client->addSubscriber($auth);
     //$response = $client->get('search/tweets.json?q=%23peukpoll&since=' . date('Y-m-d'))->send();
     $response = $client->get('search/tweets.json?q=%23peukpoll')->send();
     $data = $response->json()['statuses'];
     $tweets = array_fetch($response->json()['statuses'], 'text');
     foreach ($tweets as $tweet) {
         $values[] = explode(' ', $tweet);
     }
     for ($i = 0; $i < count($values); $i++) {
         $user = User::where('username', $data[$i]['user']['screen_name'])->first();
         if ($user == null) {
             $user = new User();
             $user->username = $data[$i]['user']['screen_name'];
             $user->save();
         }
         $tweet = Tweet::where('tweet', $data[$i]['id'])->first();
         if ($tweet == null) {
             $tweet = new Tweet();
             $tweet->x = $values[$i][0];
             $tweet->y = $values[$i][2];
             $tweet->score_x = 1;
             $tweet->score_y = 1;
             $tweet->tweet = $data[$i]['id'];
             $tweet->user()->associate($user);
             $tweet->save();
             $numberOfUpcomingTweets = UpcomingTweet::all()->count();
             if ($numberOfUpcomingTweets > 0) {
                 $upcomingTweet = new UpcomingTweet();
                 $upcomingTweet->end = date('Y-m-d H:i:s', strtotime('+ 1 year'));
                 $upcomingTweet->tweet()->associate($tweet);
                 $upcomingTweet->save();
             } else {
                 $upcomingTweet = new UpcomingTweet();
                 $upcomingTweet->end = date('Y-m-d H:i:s', strtotime('+ 1 hour'));
                 $upcomingTweet->tweet()->associate($tweet);
                 $upcomingTweet->save();
             }
         }
     }
 }
Example #24
0
 public static function jobSelectBox($jobsall = null)
 {
     // Code to resolve pgsql names
     $f_Name = 'Name';
     $f_JobID = 'JobId';
     if (Config::get('database.default') == 'pgsql') {
         $f_Name = strtolower($f_Name);
         $f_JobID = strtolower($f_JobID);
     }
     if ($jobsall == null) {
         $jobsall = Job::select($f_JobID, $f_Name)->distinct($f_Name)->orderBy($f_Name, 'asc')->get()->toArray();
     }
     $jobsName = array_fetch($jobsall, $f_Name);
     $jobsId = array_fetch($jobsall, $f_JobID);
     $jobsSelectBox = array_unique(array_combine($jobsId, $jobsName));
     natsort($jobsSelectBox);
     return $jobsSelectBox;
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     if (Auth::check()) {
         $clusters = Cluster::all();
         $clustersCount = Cluster::all()->count();
         //Get bulbs
         $bulbs = Bulb::all();
         $bulbsCount = Bulb::all()->count();
         //Get schedules
         $schedules = Schedule::all();
         $schedulesCount = Schedule::all()->count();
         $distinct_bulbs = array_fetch(DB::select("SELECT DISTINCT bulb_id FROM poweranalyzers ORDER BY bulb_id"), 'bulb_id');
         $readings = Bulb::whereIn('id', $distinct_bulbs)->get();
         $readingsCount = count($readings);
         $markers = Cluster::find($id)->bulbs;
         $markersCount = count($markers);
         return View::make('cluster')->with('markers', $markers)->with('markersCount', $markersCount)->with('clusters', $clusters)->with('clustersCount', $clustersCount)->with('bulbs', $bulbs)->with('bulbsCount', $bulbsCount)->with('readings', $readings)->with('readingsCount', $readingsCount)->with('schedules', $schedules)->with('schedulesCount', $schedulesCount);
     }
 }
Example #26
0
 public function index()
 {
     //Get the markers
     $markers = Bulb::all();
     $markersCount = Bulb::all()->count();
     $clusters = Cluster::all();
     $clustersCount = Cluster::all()->count();
     //Get bulbs
     $bulbs = Bulb::all();
     $bulbsCount = Bulb::all()->count();
     //Get distinct bulbs
     $distinct_bulbs = array_fetch(DB::select("SELECT DISTINCT bulb_id FROM poweranalyzers ORDER BY bulb_id"), 'bulb_id');
     $readings = Bulb::whereIn('id', $distinct_bulbs)->get();
     $readingsCount = count($readings);
     //Get schedules
     $schedules = Schedule::all();
     $schedulesCount = Schedule::all()->count();
     return View::make('home')->with('markers', $markers)->with('markersCount', $markersCount)->with('clusters', $clusters)->with('clustersCount', $clustersCount)->with('bulbs', $bulbs)->with('bulbsCount', $bulbsCount)->with('readings', $readings)->with('readingsCount', $readingsCount)->with('schedules', $schedules)->with('schedulesCount', $schedulesCount);
 }
Example #27
0
 public static function clientSelectBox($clientsall = null)
 {
     if ($clientsall == null) {
         $clientsall = Client::all()->toArray();
     }
     // Code to resolve pgsql names
     $f_Name = 'Name';
     $f_ClientID = 'ClientId';
     if (Config::get('database.default') == 'pgsql') {
         $f_Name = strtolower($f_Name);
         $f_ClientID = strtolower($f_ClientID);
     }
     //Both Engines :
     $clientsName = array_fetch($clientsall, $f_Name);
     $clientsId = array_fetch($clientsall, $f_ClientID);
     $clientSelectBox = array_combine($clientsId, $clientsName);
     natsort($clientSelectBox);
     return $clientSelectBox;
 }
Example #28
0
 public function __construct()
 {
     parent::__construct();
     Asset::add('select2.css', 'assets/css/select2.css');
     Asset::add('select2.min.js', 'assets/js/select2.min.js');
     /* Html Exports Tables */
     Asset::add('bootstrap-dropdown.js', 'assets/js/bootstrap-dropdown.js');
     Asset::add('tableExport.js', 'assets/js/tableExport.js');
     Asset::add('jquery.base64.js', 'assets/js/jquery.base64.js');
     Asset::add('html2canvas.js', 'assets/js/html2canvas.js');
     Asset::add('sprintf.js', 'assets/js/sprintf.js');
     Asset::add('jspdf.js', 'assets/js/jspdf.js');
     Asset::add('base64.js', 'assets/js/base64.js');
     Asset::add('volumes', 'assets/js/volumes.js');
     /* Fill Up the Select Box */
     $volumesall = Media::select(array('mediaid', 'volumename'))->groupby('volumename')->groupby('mediaid')->orderby('volumename', 'asc')->get()->toArray();
     $volumeName = array_fetch($volumesall, 'volumename');
     $volumeId = array_fetch($volumesall, 'mediaid');
     $this->volumeSelectBox = array_combine($volumeId, $volumeName);
 }
Example #29
0
 public function __construct()
 {
     parent::__construct();
     Asset::add('select2', 'assets/css/select2.css');
     Asset::container('footer')->add('momentmin', 'assets/js/moment.min.js');
     Asset::container('footer')->add('select2min', 'assets/js/select2.min.js');
     /* Html Exports Tables */
     Asset::add('bootstrap-dropdown.js', 'assets/js/bootstrap-dropdown.js');
     Asset::add('tableExport.js', 'assets/js/tableExport.js');
     Asset::add('jquery.base64.js', 'assets/js/jquery.base64.js');
     Asset::add('html2canvas.js', 'assets/js/html2canvas.js');
     Asset::add('sprintf.js', 'assets/js/sprintf.js');
     Asset::add('jspdf.js', 'assets/js/jspdf.js');
     Asset::add('base64.js', 'assets/js/base64.js');
     Asset::container('footer')->add('pools.js', 'assets/js/pools.js');
     /* Fill Up the Select Box */
     $poolall = Pool::select(array('poolid', 'name'))->orderBy('name', 'asc')->remember(10)->get()->toArray();
     $poolName = array_fetch($poolall, 'name');
     $poolId = array_fetch($poolall, 'poolid');
     $this->poolSelectBox = array_combine($poolId, $poolName);
 }
Example #30
0
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create()
 {
     //Create a new light/lamp
     $longitude = Input::get('longitude');
     $latitude = Input::get('latitude');
     //Assign coordinates to $marker array
     $marker = array('longitude' => $longitude, 'latitude' => $latitude);
     //Get clusters
     $clusters = Cluster::all();
     $clustersCount = Cluster::all()->count();
     //Get bulbs
     $bulbs = Bulb::all();
     $bulbsCount = Bulb::all()->count();
     //Get distinct bulbs
     $distinct_bulbs = array_fetch(DB::select("SELECT DISTINCT bulb_id FROM poweranalyzers ORDER BY bulb_id"), 'bulb_id');
     $readings = Bulb::whereIn('id', $distinct_bulbs)->get();
     $readingsCount = count($readings);
     //Get schedules
     $schedules = Schedule::all();
     $schedulesCount = Schedule::all()->count();
     return View::make('add_bulb')->with('marker', $marker)->with('longitude', $longitude)->with('latitude', $latitude)->with('clusters', $clusters)->with('clustersCount', $clustersCount)->with('bulbs', $bulbs)->with('bulbsCount', $bulbsCount)->with('readings', $readings)->with('readingsCount', $readingsCount)->with('schedules', $schedules)->with('schedulesCount', $schedulesCount);
 }