public function update(LocationUpdateRequest $request, $id)
 {
     $location = new Location($request->all());
     Location::where('id', $id)->update($location->getAttributes());
     flash()->success(trans('location.label.name'), trans('location.message_alert.update_success'));
     return redirect('/locations');
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($type, $id)
 {
     if ($id == 'video') {
         $events = Video::all();
         return view('video.show', compact('events'));
     } elseif ($id == 'staff') {
         $events = Staff::all();
         return view('staff.show', compact('events'));
     } elseif ($id == 'gallery') {
         $events = Image::all();
         return view('gallery.show', compact('events'));
     } else {
         $event = Event::where('slug', $id)->where('type', $type)->first();
         $location = Location::where('event_id', $event->id)->first();
         $slider = EventImage::where('event_id', $event->id)->orderBy(\DB::raw('RAND()'))->take(4)->get();
         $gallery = EventImage::where('event_id', $event->id)->first();
         if ($event->type == $type) {
             if ($event->status == 1) {
                 return view($type . '.show', compact('event', 'location', 'slider', 'gallery'));
             } else {
                 return redirect('/' . $type . '/');
             }
         }
     }
 }
Beispiel #3
0
 /**
  *
  * @return view
  */
 public function dashboard_by_location()
 {
     // summary by location
     $locations = \App\Location::where('parent_id', 0)->orderBy('name')->get();
     for ($i = 0; $i < count($locations); $i++) {
         $nodesAll = \App\Node::where('location_id', $locations[$i]->id)->get();
         $nodesUp = \App\Node::where('location_id', $locations[$i]->id)->where('ping_success', '100')->get();
         $locations[$i]->nodesUp = $nodesUp->count();
         $locations[$i]->nodesDown = $nodesAll->count() - $nodesUp->count();
         // no node assigned in this project
         if ($nodesAll->count() == 0) {
             $locations[$i]->nodesUpnPercent = 0;
             $locations[$i]->nodesDownPercent = 0;
         } else {
             $locations[$i]->nodesUpPercent = $nodesUp->count() / $nodesAll->count() * 100;
             $locations[$i]->nodesDownPercent = 100 - $locations[$i]->nodesUpPercent;
             // to prevent too small click area
             if ($locations[$i]->nodesDownPercent > 0 && $locations[$i]->nodesDownPercent < 10) {
                 $locations[$i]->nodesUpPercent -= 10;
                 $locations[$i]->nodesDownPercent += 10;
             }
             if ($locations[$i]->nodesUpPercent > 0 && $locations[$i]->nodesUpPercent < 10) {
                 $locations[$i]->nodesUpPercent += 10;
                 $locations[$i]->nodesDownPercent -= 10;
             }
         }
     }
     return view('pages.dashboard_by_location', compact('locations'));
 }
 /**
  * Display a list of all locations.
  *
  * @param  Request  $request
  * @return Response
  */
 public function index(Request $request)
 {
     $showLocations = DB::select('select * from configs where id = ?', [2]);
     if ($showLocations[0]->value === '1') {
         return view('locations.index', ['locations' => Location::where('status', 1)->orderBy('name')->get()]);
     } else {
         return view('locations.index', ['locations' => []]);
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $rp_arr = [];
     $user = \Auth::user();
     if ($user->role->name != 'guest') {
         $data = $request->json()->get('data');
         for ($i = 0; $i < count($data); $i++) {
             $order = new \App\Order();
             $from = Carbon::parse($data[$i]['from']);
             $to = Carbon::parse($data[$i]['to']);
             $order['from'] = $from;
             $order['to'] = $to;
             $order['location_id'] = \App\Location::where('name', $data[$i]['location'])->first()['id'];
             //$order['user_id'] = $user['id'];
             // count the similar records
             // if the num of them reaches upper limite then operation would be aborted
             $num_of_ordered = \App\Order::where('from', $from)->where('to', $to)->where('location_id', $order['location_id'])->count();
             $allowance = \App\Location::findOrFail($order['location_id'])->capacity;
             //dd($num_of_ordered);
             // $num_of_ordered can only be 0 or 1 in this case
             if ($num_of_ordered < $allowance) {
                 $user->orders()->save($order);
                 // Only one vacancy left before the saving statement.
                 if ($allowance - $num_of_ordered <= 1) {
                     array_push($rp_arr, ['from' => $order['from'], 'to' => $order['to'], 'status' => '0']);
                 } else {
                     array_push($rp_arr, ['from' => $order['from'], 'to' => $order['to'], 'status' => '1']);
                 }
             }
             /*else {
                   array_push($rp_arr, ['from' => $order['from'], 'to' => $order['to'], 'status' => '0']);
               }*/
         }
         /*if (\Auth::user()->orders()->save($order)) {
         
                         // \Mail::send('emails.test', [], function ($m) {
                         //     $m->from('*****@*****.**', 'sonic');
                         //     $m->to('*****@*****.**', 'sonic')->subject('Your Reminder!');
                         // });
                             return back()->withInput();
         
                         // $headers = 'From: soniczhangss@gmail.com' . "\r\n" . 'Reply-To: soniczhangss@gmail.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
                         // if (mail('*****@*****.**', 'My Subject', 'blah blah', $headers)) {
                         //     return response()->json(['response' => 'successful']);
                         // } else {
                         //     return response()->json(['response' => 'failed']);
                         // }
                         //dd(mail('*****@*****.**', 'My Subject', 'blah blah', $headers));
                         
                         //return response()->json(['response' => 'successful']);
                         
                     }*/
     }
     //return back()->withInput();
     return response()->json(['data' => $rp_arr]);
 }
Beispiel #6
0
 public function showLocations(Request $request)
 {
     $q = $request->input('q');
     $json['results'] = [];
     $results = Location::where('name', 'LIKE', "%{$q}%")->take(10)->lists('name', 'id');
     foreach ($results as $key => $value) {
         $json['results'][] = array('id' => $key, 'text' => $value);
     }
     return json_encode($json);
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $travel_id = Request::input('travel_id');
     $locations = Location::where('travel_id', $travel_id)->orderBy('order', 'asc')->get();
     if (count($locations) > 0) {
         return $locations;
     } else {
         return [];
     }
 }
Beispiel #8
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (Session::has('currency')) {
         return $next($request);
     }
     $ip = $_SERVER['REMOTE_ADDR'];
     $data = \SypexGeo::get($ip);
     $currency = 'BYR';
     if (isset($data['country']['iso'])) {
         switch ($data['country']['iso']) {
             case 'KZ':
             case 'RU':
                 $currency = 'RUB';
                 break;
             case 'BY':
                 $currency = 'BYR';
                 break;
                 //Euro zone countries
             //Euro zone countries
             case 'AT':
             case 'BE':
             case 'DE':
             case 'GR':
             case 'IE':
             case 'IT':
             case 'ES':
             case 'CY':
             case 'LV':
             case 'LT':
             case 'LU':
             case 'MT':
             case 'NL':
             case 'PT':
             case 'SK':
             case 'SI':
             case 'FI':
             case 'FR':
             case 'EE':
                 $currency = 'EUR';
                 break;
             case 'GB':
                 $currency = 'GBP';
                 break;
             default:
                 $currency = 'USD';
                 break;
         }
     }
     Session::put('currency', $currency);
     $isInBase = \App\Location::where('ip', $ip)->twentyFour()->first();
     if (!$isInBase) {
         \App\Location::create(['ip' => $ip]);
     }
     return $next($request);
 }
Beispiel #9
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $ip = $_SERVER['REMOTE_ADDR'];
     $isInBase = \App\Location::where('ip', $ip)->twentyFour()->first();
     if (!$isInBase) {
         $data = \SypexGeo::get($ip);
         $sData = serialize($data);
         $visitor = \App\Location::create(['ip' => $ip, 'content' => $sData]);
     }
     return $next($request);
 }
Beispiel #10
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     //
     $q = \Request::get('q');
     if ($q != '') {
         $locations = \App\Location::where('name', 'RLIKE', $q)->where('id', '>', 1)->paginate(200);
     } else {
         $locations = \App\Location::where('id', '>', 1)->paginate(200);
     }
     return view('locations.index', compact('locations', 'q'));
 }
Beispiel #11
0
 public function map($location_id)
 {
     $oLocation = Location::where('id', '=', $location_id)->first();
     if (!$oLocation) {
         return '<center><h1>Locación no valida :P</h1></center>';
     } else {
         $valores['latitude'] = (double) $oLocation->latitude;
         $valores['longitude'] = (double) $oLocation->longitude;
         $valores['date'] = $oLocation->date;
         return view('map', compact('valores'));
     }
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request)
 {
     $data = $request->json()->get('data');
     $locationOld = $data[0]['locationOld'];
     $location = $data[0]['location'];
     $allowance = $data[0]['allowance'];
     $locationRec = \App\Location::where('name', $locationOld);
     if ($allowance == '') {
         $locationRec->update(['name' => $location]);
     } else {
         $locationRec->update(['name' => $location, 'capacity' => $allowance]);
     }
 }
 /**
  * Query by zipcode
  * @param  string $zipcode 5 digit zipcode - validated in route
  * @return json
  */
 public function zipcode($zipcode)
 {
     $resp = new \stdClass();
     $l = Location::where('zip', intval($zipcode))->first();
     if (null === $l) {
         return ['status' => 'error', 'message' => 'zipcode not found'];
     }
     $reps = Representative::atLocation($l);
     usort($reps, 'rankSort');
     $resp->reps = $reps;
     $resp->location = $l;
     return response()->json($resp);
 }
Beispiel #14
0
 /**
  * Generate Location Associate Array
  *
  * @return Array
  */
 public static function all_select($show_all = '')
 {
     $_ret = array();
     $_ret[''] = '-- location --';
     if ($show_all == 'all') {
         $_ret[1] = '** ALL **';
     }
     $locations = \App\Location::where('id', '>', 1)->get();
     foreach ($locations as $location) {
         $_ret[$location->id] = $location->name;
     }
     return $_ret;
 }
 public static function searchLocationTweets($locName, $locLat, $locLng)
 {
     $location = Location::where('latitude', '=', round($locLat, 7))->where('longitude', '=', round($locLng, 7))->first();
     $tweets = null;
     if ($location == null) {
         $location = new Location();
         $location->name = $locName;
         $location->latitude = round($locLat, 7);
         $location->longitude = round($locLng, 7);
         $locRet = $location->save();
         //save search history
         $search = new Search();
         $search->location_id = $location->id;
         $search->user = $_COOKIE['user'];
         $search->save();
         $tweets = self::getTweets($locName, round($locLat, 7), round($locLng, 7));
         //save tweets
         foreach ($tweets as $tweet) {
             $tweet->search_id = $search->id;
             $tweet->save();
         }
     } else {
         $search = Search::where('location_id', '=', $location->id)->orderBy('created_at', 'desc')->first();
         $searchTime = strtotime($search->created_at);
         //save new search
         $newSearch = new Search();
         $newSearch->location_id = $location->id;
         $newSearch->user = $_COOKIE['user'];
         $newSearch->save();
         //if search is older than 1 hour, tweet again
         if ($searchTime <= strtotime('-' . Config::get('app.cache_duration') . ' minutes')) {
             $tweets = self::getTweets($locName, round($locLat, 7), round($locLng, 7));
             //save tweets
             foreach ($tweets as $tweet) {
                 $tweet->search_id = $search->id;
                 $tweet->save();
             }
         } else {
             //get last search with tweets
             $search = DB::table('searches')->where('location_id', '=', $location->id)->whereExists(function ($query) {
                 $query->select(DB::raw(1))->from('tweets')->whereRaw('tweets.search_id = searches.id');
             })->orderBy('created_at', 'desc')->first();
             $tweets = Tweet::where('search_id', '=', $search->id)->get();
         }
     }
     return $tweets;
 }
 /**
  * Function that gets locations of specified type.
  *
  * @return Response
  */
 public function getLocations()
 {
     // Validate Input.
     $validator = Validator::make(Input::all(), array('type' => 'required'));
     if ($validator->fails()) {
         return response()->json(['error' => 'Informacion incompleta!']);
     }
     // Check that user is part of authorized staff.
     if (Auth::user()->Type != 1) {
         // If they are unauthorized no point in returning anything.
         return response()->json(array());
     }
     $locations = Location::where('Type', '=', Input::get('type'))->get();
     $response['locationList'] = array();
     foreach ($locations as $location) {
         array_push($response['locationList'], array('id' => $location->Id, 'name' => $location->Name));
     }
     // Return location list.
     return response()->json($response);
 }
 /**
  * Check if user input (product ID) is correct and available
  */
 public function check()
 {
     $productId = Request::get('id');
     $userid = Auth::User()->id;
     //Check if another added this device (some location) or you added this(location with your userid)?
     $location = Location::where('product_id', $productId)->first();
     if ($location) {
         if ($location->user_id == $userid) {
             \Session::flash('flash_message', 'This Product is already added to your account');
             return redirect('products');
         }
     }
     //Check if Product already selfregistered/exist
     $product = Product::where('id', $productId)->first();
     if (!$product) {
         \Session::flash('flash_message', 'There was never a Product that connected to this Webserver with this ID: ' . $productId);
         return redirect('product');
     }
     return view('products.add', compact('product'));
 }
 public function create(Request $req)
 {
     $loc_name = $req->get("loc_name");
     $brendblusser = false;
     if ($req->extinguisher == "on") {
         $brendblusser = true;
     }
     if ($loc_name == "") {
         return back();
     }
     $location = Location::where('name', '=', $loc_name)->first();
     if ($location == null) {
         $location = new \App\Location();
         $location->name = $loc_name;
         $location->brendblusser = $brendblusser;
         $location->save();
     }
     QrCode::format("png")->size(400)->margin(0)->generate("{loc_id:\"" . $location->id . "\"}", "../public/qrcode.png");
     return response()->download("../public/qrcode.png", $loc_name . ".png");
 }
Beispiel #19
0
 /**
  * Edit Location /
  */
 public function editLocation($timeline_id, $location_id, Request $request)
 {
     $timeline = \App\Timeline::where('id', '=', $timeline_id)->first();
     $location = \App\Location::where('id', '=', $location_id)->first();
     if ($location) {
         if ($request->input('showForm') == 'true') {
             return view('locations.editLocation')->with('showForm', 'true')->with('location', $location)->with('timeline', $timeline);
         } else {
             // Validate the request data
             $this->validate($request, ['name' => 'required']);
             $user = \Auth::user();
             $location->name = $request->input('name');
             $location->description = $request->input('description');
             $location->last_modified_by = $user->id;
             $location->save();
             return view('locations.editLocation')->with('showForm', 'false')->with('location', $location)->with('timeline', $timeline);
         }
     } else {
         return "Update failed. Location does not exist.";
     }
 }
Beispiel #20
0
 /**
  * convert api data to contact my reps data format
  * @param  object $data google response data
  * @return object       contact my reps api response
  */
 public function validate($data)
 {
     $response = (object) ['reps' => [], 'divisions' => []];
     if (isset($data->normalizedInput)) {
         $l = $data->normalizedInput;
         $city = ucwords($l->city);
         $response->location = (object) array('city' => $city, 'state' => $l->state, 'zip' => $l->zip);
         if (!empty($city) && !empty($l->zip)) {
             $location = Location::where('zip', intval($l->zip))->first();
             if (null !== $location) {
                 $location->city = $city;
                 $location->save();
             }
         }
     }
     if (!isset($data->divisions)) {
         return $response;
     }
     $response->divisions = array_keys((array) $data->divisions);
     if (!isset($data->offices)) {
         return $response;
     }
     foreach ($data->offices as $office) {
         if (!Representative::isValidOffice($office->name)) {
             continue;
         }
         $divisionId = $office->divisionId;
         $l = divisions_split([$divisionId]);
         foreach ($office->officialIndices as $i) {
             $d = $data->officials[$i];
             $d->office = $office->name;
             $d->division = $divisionId;
             if (isset($l['state'])) {
                 $d->state = $l['state'];
             }
             $rep = Representative::find($d);
             // if (is_null($rep)) $rep = new Representative((array) $d);
             if (null === $rep) {
                 continue;
             }
             //for now no new reps
             if (in_array('google', $rep->sources)) {
                 $response->reps[] = $rep;
                 continue;
             }
             if (empty($rep->name) && isset($d->name)) {
                 $rep->name = $d->name;
             }
             if (empty($rep->party) && isset($d->party)) {
                 $rep->party = $d->party;
             }
             if (empty($rep->photo) && isset($d->photoUrl)) {
                 $rep->photo = $d->photoUrl;
             }
             if (empty($rep->address) && isset($d->address)) {
                 $new = [];
                 $a = $d->address;
                 if (is_array($a)) {
                     $a = $a[0];
                 }
                 if (!empty($a->line1)) {
                     $new[] = ucwords($a->line1);
                 }
                 if (!empty($a->line2)) {
                     $new[] = ucwords($a->line2);
                 }
                 if (!empty($a->line3)) {
                     $new[] = ucwords($a->line3);
                 }
                 if (!empty($a->city) && !empty($a->state) && !empty($a->zip)) {
                     $new[] = $a->city . ', ' . $a->state . ' ' . $a->zip;
                 }
                 $rep->address = $new;
             }
             if (isset($d->phones) && count($d->phones) > 0) {
                 $phones = $rep->phones ?? [];
                 foreach ($d->phones as &$p) {
                     $p = str_replace(['(', ') '], ['', '-'], $p);
                     if (!in_array($p, $phones)) {
                         array_push($phones, $p);
                     }
                 }
                 $rep->phones = $phones;
                 if (!isset($rep->phone)) {
                     $rep->phone = $phones[0];
                 }
             }
             if (isset($d->urls) && count($d->urls) > 0) {
                 $urls = $rep->urls ?? [];
                 foreach ($d->urls as $u) {
                     if (!in_array($u, $urls)) {
                         array_push($urls, $u);
                     }
                 }
                 $rep->urls = $urls;
                 if (!isset($rep->website)) {
                     $rep->website = $urls[0];
                 }
             }
             if (isset($d->emails) && count($d->emails) > 0) {
                 $emails = $rep->emails ?? [];
                 foreach ($d->emails as $e) {
                     if (!in_array($e, $emails)) {
                         array_push($emails, $e);
                     }
                 }
                 $rep->emails = $emails;
                 if (!isset($rep->email)) {
                     $rep->email = $emails[0];
                 }
             }
             if (isset($d->channels)) {
                 foreach ($d->channels as $c) {
                     $key = strtolower($c->type) . '_id';
                     if (!isset($rep->{$key})) {
                         $rep->{$key} = $c->id;
                     }
                 }
             }
             $rep->addSource('google');
             $rep->save();
             $response->reps[] = $rep;
         }
     }
     return $response;
 }
 public function city($city, Request $request)
 {
     $thiscity = Location::where('link', $city)->firstOrFail();
     $variables = array('pickup_date_part' => $request->input('pickup_date_part'));
     $id = $thiscity->id;
     $start_link = $request->input('start');
     $start_id = 1;
     /* prague */
     if (!empty($start_link)) {
         $start_location = Location::where('link', $start_link)->first();
         if ($start_location) {
             $start_id = $start_location->id;
         }
     }
     $directions = Direction::with('income_list.car_type')->where('destination_id', $id)->where('start_id', $start_id)->get();
     //for title in blade
     $direction = Direction::with('start', 'end')->where('destination_id', $id)->where('start_id', $start_id)->first();
     $incomes = Income_list::with('car_type', 'direction')->whereNull('user_id')->whereHas('direction', function ($query) use($id, $start_id) {
         $query->where('destination_id', $id)->where('start_id', $start_id);
     })->get();
     JavaScript::put(['variables' => $variables, 'incomes' => $incomes, 'direction' => $direction, 'directions' => $directions]);
     return view('reservation.city')->with(['thiscity' => $thiscity, 'direction' => $direction]);
 }
 public function parseFile($file, $chamber, $state)
 {
     //first word of first line is state
     //line 2 is tags
     //state,zip,sld
     $count = 0;
     for ($j = 2; $j < count($file); $j++) {
         $line = explode(",", $file[$j]);
         $zip = trim($line[1]);
         $district = ltrim(trim($line[2]), "0");
         $loc = Location::where('zip', intval($line[1]))->first();
         if (null === $loc) {
             $loc = new Location();
             $loc->zip = intval($zip);
         }
         $loc->state_name = ucwords(strtolower($state));
         $sld = 'sld' . $chamber;
         if (isset($loc->{$sld})) {
             $districts = $loc->{$sld};
             if (!in_array($district, $districts)) {
                 array_push($districts, $district);
                 $loc->{$sld} = $districts;
                 $count++;
             }
         } else {
             $loc->{$sld} = [$district];
             $count++;
         }
         $loc->save();
     }
     echo "count: {$count}\n";
 }
Beispiel #23
0
 public function getZip($city, $state)
 {
     return Location::where('city', '=', $city)->where('state', '=', $state)->first()->zip;
 }
Beispiel #24
0
 /**
  * Get all locations that belong to building_level
  * @param $id
  * @return mixed
  */
 public function getLocations($id)
 {
     return $this->location->where('level_id', '=', $id);
 }
Beispiel #25
0
 /**
  * Search for a location by city or zip
  *
  * @param string
  * @return json
  * @author PJ
  */
 public function show($location)
 {
     /**
      * EXAMPLE 
      * 
      * select *
      * from `locations`
      * where `zip` like 'naper%' or `city` like 'naper%'
      * group by city, zip
      */
     $locations = App\Location::where('zip', 'like', $location . '%')->orWhere('city', 'like', $location . '%')->groupBy(['city', 'zip'])->get();
     if (!$locations->isEmpty()) {
         return Response::json($locations, 200);
     }
     return Response::json(['error' => ['message' => 'Location not found', 'status_code' => 404]], 404);
 }
 public function travel()
 {
     $user = Auth::user();
     $radioButton = Input::get('radio');
     if ($radioButton == 'England') {
         $location = Location::where('location', '=', 'England')->first();
         if ($user->money >= $location->price) {
             $user->money -= $location->price;
             $user->location = "England";
             $user->save();
             session()->flash('flash_message', 'You traveled!');
             return redirect('/travel');
         } else {
             session()->flash('flash_message_important', 'Not Enough Money!');
             return redirect('/travel');
         }
     } elseif ($radioButton == 'France') {
         $location = Location::where('location', '=', 'France')->first();
         if ($user->money >= $location->price) {
             $user->money -= $location->price;
             $user->location = "France";
             $user->save();
             session()->flash('flash_message', 'You traveled!');
             return redirect('/travel');
         } else {
             session()->flash('flash_message_important', 'Not Enough Money!');
             return redirect('/travel');
         }
     } elseif ($radioButton == 'USA') {
         $location = Location::where('location', '=', 'USA')->first();
         if ($user->money >= $location->price) {
             $user->money -= $location->price;
             $user->location = "USA";
             $user->save();
             session()->flash('flash_message', 'You traveled!');
             return redirect('/travel');
         } else {
             session()->flash('flash_message_important', 'Not Enough Money!');
             return redirect('/travel');
         }
     } elseif ($radioButton == 'Brazil') {
         $location = Location::where('location', '=', 'Brazil')->first();
         if ($user->money >= $location->price) {
             $user->money -= $location->price;
             $user->location = "Brazil";
             $user->save();
             session()->flash('flash_message', 'You traveled!');
             return redirect('/travel');
         } else {
             session()->flash('flash_message_important', 'Not Enough Money!');
             return redirect('/travel');
         }
     } elseif ($radioButton == 'Belgium') {
         $location = Location::where('location', '=', 'Belgium')->first();
         if ($user->money >= $location->price) {
             $user->money -= $location->price;
             $user->location = "Belgium";
             $user->save();
             session()->flash('flash_message', 'You traveled!');
             return redirect('/travel');
         } else {
             session()->flash('flash_message_important', 'Not Enough Money!');
             return redirect('/travel');
         }
     } elseif ($radioButton == 'Iraq') {
         $location = Location::where('location', '=', 'Iraq')->first();
         if ($user->money >= $location->price) {
             $user->money -= $location->price;
             $user->location = "Iraq";
             $user->save();
             session()->flash('flash_message', 'You traveled!');
             return redirect('/travel');
         } else {
             session()->flash('flash_message_important', 'Not Enough Money!');
             return redirect('/travel');
         }
     } else {
         session()->flash('flash_message_important', 'Failed to travel!');
         return redirect('/travel');
     }
 }
Beispiel #27
0
 public function find(Request $request)
 {
     if ($request->has('state')) {
         $location = Location::where(['state' => $request->input('state')])->first();
         if (empty($location)) {
             abort(404, 'State not found');
         } else {
             return redirect('reps/find/state/' . $location->state);
         }
     }
 }
Beispiel #28
0
<div class="form-group">
 {!! Form::label('ip_address', 'IP Address', ['class' => 'control-label col-sm-2']) !!}
 <div class="col-sm-3">
  {!! Form::text('ip_address', null, ['class' => 'form-control']) !!}
 </div>
</div>

<div class="form-group">
 {!! Form::label('location_id', 'Location', ['class' => 'control-label col-sm-2']) !!}
 <div class="col-sm-3">


<select class="form-control" name="location_id">
<?php 
// {!! Form::select('location_id', \App\Location::all_select(), $node->location_id, ['class' => 'form-control'] ) !!}
$locations = \App\Location::where('id', '>', 1)->get();
foreach ($locations as $location) {
    print '<option ';
    if ($location->id == $node->location_id) {
        print 'selected';
    }
    print ' value="' . $location->id . '">';
    if ($location->parent_id > 0) {
        print ' &nbsp;&middot; ';
    }
    print $location->name . '</option>';
}
?>
</select>

Beispiel #29
0
 public function getLocation(Request $request)
 {
     return Location::where('external_id', $request->data)->first();
 }
Beispiel #30
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $event = Event::findOrFail($id);
     $location = Location::where('event_id', $event->id)->firstOrFail();
     return view('event.show', compact('event', 'location'));
 }