예제 #1
0
 public function addLocation(Request $request)
 {
     $location = new Location();
     $location->picture_id = $this->id;
     $location->getLocation($this, $request);
     $location->save();
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // Model::unguard();
     //create a user
     $user = new User();
     $user->email = "*****@*****.**";
     $user->password = Hash::make('password');
     $user->save();
     //create a country
     $country = new Country();
     $country->name = "United States";
     $country->id = 236;
     $country->save();
     //create a state
     $state = new State();
     $state->name = "Pennsylvania";
     $state->id = 1;
     $state->save();
     $city = new City();
     $city->name = "Pittsburgh";
     $city->id = 1;
     $city->save();
     //create a location
     $location = new Location();
     $location->city_id = $city->id;
     $location->state_id = $state->id;
     $location->country_id = $country->id;
     $location->latitude = 40.44;
     $location->longitude = 80;
     $location->code = '15212';
     $location->address_1 = "100 Main Street";
     $location->save();
     //create a new accommodation
     $accommodation = new Accommodation();
     $accommodation->name = "Royal Plaza Hotel";
     $accommodation->location_id = $location->id;
     // $location->id;
     $accommodation->description = "A modern, 4-star hotel";
     $accommodation->save();
     //create a room
     $room1 = new App\Room();
     $room1->id = 1;
     $room1->room_number = 'A01';
     $room1->accommodation_id = $accommodation->id;
     $room1->save();
     //create another room
     $room2 = new Room();
     $room2->id = 2;
     $room2->room_number = 'A02';
     $room2->accommodation_id = $accommodation->id;
     $room2->save();
     //create the room array
     $rooms = [$room1, $room2];
     //$this->call('AuthorsTableSeeder');
     //$this->command->info('Authors table seeded!');
     //
     $this->call(AmenityTableSeeder::class);
     $this->command->info('Amenity Class Seeded table seeded!');
 }
예제 #3
0
 public static function storeLocation($request)
 {
     $location = new Location();
     $location->doctor_id = $request->get('doctor_id');
     $location->address = $request->get('address');
     $location->save();
     return redirect()->back()->with('message', 'Location was added.');
 }
 function add(Request $request)
 {
     $this->validate($request, ['address_name' => 'required', 'postalCode_name' => 'required', 'city_name' => 'required', 'province_name' => 'required', 'country_name' => 'required']);
     $json_raw = Input::get('maps_json_name');
     $json_obj = json_decode($json_raw);
     $city = '';
     $country = '';
     $province = '';
     $street_num = '';
     $street_name = '';
     $postal_code = '';
     $lat = $json_obj[0]->geometry->location->lat;
     $lng = $json_obj[0]->geometry->location->lng;
     foreach ($json_obj[0]->address_components as $comp) {
         switch ($comp->types[0]) {
             case 'street_number':
                 //STREET NUMBER
                 $street_num = $comp->long_name;
                 break;
             case 'route':
                 //STREET NAME
                 $street_name = $comp->long_name;
                 break;
             case 'administrative_area_level_1':
                 //STATE/PROVINCE
                 $province = $comp->short_name;
                 break;
             case 'postal_code':
                 //POSTAL CODE
                 $postal_code = $comp->long_name;
                 break;
             case 'country':
                 //COUNTRY
                 $country = $comp->long_name;
                 break;
             case 'neighborhood':
             case 'locality':
                 $city = $comp->long_name;
                 break;
         }
     }
     if ($city == '' | $country == '' | $province == '' | $street_name == '' | $street_num == '' | $postal_code == '') {
         return redirect('addProperty')->withErrors(["We can't find your full address, please update your info and resubmit"]);
     }
     $property = new Location();
     $property->user()->associate(Auth::user());
     $property->street_address = $street_num . " " . $street_name;
     $property->postal_code = $postal_code;
     $property->province = $province;
     $property->country = $country;
     $property->longitude = $lng;
     $property->latitude = $lat;
     $property->city = $city;
     // $property->image_path = $filename;
     $property->save();
     return redirect('profileProperties');
 }
예제 #5
0
 public function saveLocation(Request $request)
 {
     $location = new Location();
     $location->lattitude = $request->input('lattitude');
     $location->longitude = $request->input('longitude');
     $location->post_id = $request->input('post_id');
     $location->user_id = Auth::id();
     $location->save();
     return response()->json($location);
 }
 public function saveReferees(Season $season, Competition $competition, Request $request)
 {
     $data = $request->all();
     $competition->referees()->wherePivot('season_id', '=', $season->id)->detach();
     $pairs = $this->getPairs($season, $competition);
     foreach ($pairs as $pair) {
         $pair->active = 0;
         $pair->save();
     }
     $response = ['refs' => array(), 'crefs' => array()];
     $country = Country::find($data['country']);
     $refs = json_decode($data['referees'], true);
     foreach ($refs as $ref) {
         $newRef = $competition->storeReferee($ref, $season, 0, $country);
         if (array_key_exists('styled', $ref)) {
             if ($ref['styled'] == 'new') {
                 $newRef['location'] = Location::find($newRef->location_id)->name;
                 array_push($response['refs'], $newRef);
             }
         }
     }
     $crefs = json_decode($data['court_referees'], true);
     foreach ($crefs as $cref) {
         $newRef = $competition->storeReferee($cref, $season, 1, $country);
         if (array_key_exists('styled', $cref)) {
             if ($cref['styled'] == 'new') {
                 $newRef['location'] = Location::find($newRef->location_id)->name;
                 array_push($response['crefs'], $newRef);
             }
         }
     }
     $response['pairs'] = $this->getPairs($season, $competition)->toArray();
     return $response;
 }
예제 #7
0
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(LocationRequest $request, $id)
 {
     $location = Location::findOrFail($id);
     $location->fill($request->all());
     $location->save();
     return Redirect::back()->with("good", "Successfully updated location.");
 }
 public function getUserLocationsAndActions($id)
 {
     $alluserlocation = UserLocation::Where('user_id', '=', $id)->get();
     $user_locations = Location::WhereIn('id', $alluserlocation)->get();
     $user_actions = UserAction::Where('user_id', '=', $id)->get();
     return response()->json(["Response" => "success", "Actions" => unserialize($user_actions), "Locations" => $user_locations]);
 }
예제 #9
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Location::create(['name' => 'LO001']);
     Location::create(['name' => 'LO002']);
     Location::create(['name' => 'LO003']);
     Location::create(['name' => 'LO004']);
 }
예제 #10
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('locations')->truncate();
     Location::create(['name' => 'Phase 1, Level 1']);
     Location::create(['name' => 'Phase 1, Level 2']);
     Location::create(['name' => 'Phase 1, Level 3']);
     Location::create(['name' => 'Phase 2, Level 1']);
     Location::create(['name' => 'Phase 2, Level 2']);
     Location::create(['name' => 'Phase 2, Level 3']);
     Location::create(['name' => 'Phase 3, Level 1']);
     Location::create(['name' => 'Phase 3, Level 2']);
     Location::create(['name' => 'Phase 3, Level 3']);
     DB::table('areas')->truncate();
     Area::create(['name' => 'AME']);
     Area::create(['name' => 'M&W']);
     Area::create(['name' => 'Ramp']);
     Area::create(['name' => 'SCI']);
     Area::create(['name' => 'Tool Install']);
     DB::table('categories')->truncate();
     Category::create(['name' => 'Spec Gas']);
     Category::create(['name' => 'Electrical']);
     Category::create(['name' => 'Base Build']);
     Category::create(['name' => 'Design Request']);
     Category::create(['name' => 'Layout Optimization']);
     Category::create(['name' => 'Safety']);
     DB::table('status')->truncate();
     Status::create(['name' => 'New', 'slug' => 'new']);
     Status::create(['name' => 'Open/Needs Further Review', 'slug' => 'open-needs-further-review']);
     Status::create(['name' => 'Waiting for Approval', 'slug' => 'waiting-for-approval']);
     Status::create(['name' => 'Rejected', 'slug' => 'rejected']);
     Status::create(['name' => 'Approved', 'slug' => 'approved']);
 }
 public function index()
 {
     // $locations = Location::all();
     // return view('locations',['locations'=>$locations]);
     $locations = Location::with('stories')->get();
     return view('locations', ['locations' => $locations]);
 }
예제 #12
0
 public function destroy($id)
 {
     $location = \App\Location::FindOrFail($id);
     $location->delete();
     \Session::flash('flash_message', 'Location has been deleted.');
     return redirect('locations');
 }
예제 #13
0
 public function edit($id)
 {
     $activity = Activity::find($id);
     $cars = Car::lists('name', 'id');
     $customers = Customer::lists('name', 'id');
     $locations = Location::lists('name', 'id');
     $costs = null;
     $items = null;
     $ondayOtherCosts = null;
     if ($activity->type == "On Day") {
         $data = Onday::where('activity_id', '=', $id)->get()->pop();
         $ondayOtherCosts = OndayOtherCost::where('onday_id', $data->id)->get();
     } else {
         if ($activity->type == "Maintenance") {
             $data = Maintenance::where('activity_id', '=', $id)->get()->pop();
             $costs = $activity->maintenance->items;
             $items = Item::lists('name', 'id')->sort();
         } else {
             if ($activity->type == "Nil") {
                 $data = Nil::where('activity_id', '=', $id)->get()->pop();
             }
         }
     }
     return view('activity.edit', ['activity' => $activity, 'data' => $data, 'cars' => $cars, 'customers' => $customers, 'locations' => $locations, 'costs' => $costs, 'items' => $items, 'ondayOtherCosts' => $ondayOtherCosts]);
 }
예제 #14
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $locations = Cache::remember('locations', 15, function () {
         return Location::orderBy('name')->get();
     });
     return response()->json(['data' => $locations], 200);
 }
예제 #15
0
파일: Search.php 프로젝트: phpfour/ah
 /**
  * @return ElasticaQuery
  */
 private function prepareQuery($params, $start = null, $limit = null)
 {
     $query = null;
     $filter = null;
     $sort = ['_score' => 'desc'];
     // We'd like to search in both title and description for keywords
     if (!empty($params['keywords'])) {
         $query = new QueryString($params['keywords']);
         $query->setDefaultOperator('AND')->setFields(['title', 'description']);
     }
     // Add location filter is location is selected from autosuggest
     if (!empty($params['location_id'])) {
         $location = Location::find($params['location_id']);
         $filter = new GeoDistance('location', ['lat' => $location->lat, 'lon' => $location->lon], $params['radius'] . 'mi');
         // Sort by nearest hit
         $sort = ['_geo_distance' => ['jobs.location' => [(double) $location->lon, (double) $location->lat], 'order' => 'asc', 'unit' => 'mi']];
     }
     // If neither keyword nor location supplied, then return all
     if (empty($params['keywords']) && empty($params['location_id'])) {
         $query = new MatchAll();
     }
     // We need a filtered query
     $elasticaQuery = new ElasticaQuery(new Filtered($query, $filter));
     $elasticaQuery->addSort($sort);
     // Offset and limits
     if (!is_null($start) && !is_null($limit)) {
         $elasticaQuery->setFrom($start)->setSize($limit);
     }
     // Set up the highlight
     $elasticaQuery->setHighlight(['order' => 'score', 'fields' => ['title' => ['fragment_size' => 100], 'description' => ['fragment_size' => 200]]]);
     return $elasticaQuery;
 }
예제 #16
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'));
 }
예제 #17
0
 public static function boot()
 {
     parent::boot();
     static::creating(function ($model) {
         if ($model->status == null) {
             $model->status = static::CREATE;
         }
         if ($model->qty == null) {
             $model->qty = 1;
         }
         if ($model->location_id != null) {
             $location = Location::find($model->location_id, ['name']);
             if ($location) {
                 $model->location_name = $location->name;
             }
         }
     });
     static::created(function ($model) {
     });
     static::updating(function ($model) {
         if ($model->qty == null) {
             $model->qty = 1;
         }
     });
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $locations = Location::all()->toArray();
     /*$receptionist = Receptionist::where('role_id', '=', 3)->get();*/
     $receptionist = DB::table('users')->where('users.role_id', '=', 3)->join('locations', 'users.location_id', '=', 'locations.id')->get(['users.*', 'locations.name as location']);
     return Response::json(array('allreceptionists' => $receptionist, 'locations' => $locations));
 }
예제 #19
0
 /**
  * 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 . '/');
             }
         }
     }
 }
예제 #20
0
 public function edit($id)
 {
     $request = Request::with(['equipment', 'area', 'location', 'category', 'uploads', 'approvers', 'status', 'actions' => function ($query) {
         $query->orderBy('created_at', 'desc');
     }, 'actions.submitted', 'comments.author' => function ($query) {
         $query->orderBy('created_at', 'asc');
     }])->find($id);
     if (is_null($request)) {
         return view('security.not-found');
     }
     $data['request'] = $request;
     $data['areas'] = Area::all(['id', 'name']);
     $data['organizations'] = Organization::all();
     $data['categories'] = Category::all(['id', 'name']);
     $data['locations'] = Location::all(['id', 'name']);
     $data['approvers'] = Approval::getRecent($id);
     $data['hasApproved'] = Approval::hasApproved($id)->exists();
     if ($request->Status->name == 'Approved') {
         return view('request.view', $data);
     }
     if ($request->submitted_by != Auth::User()->id && !Auth::User()->hasRole(['administrator', 'approver'])) {
         return view('security.401');
     }
     return view('request.edit', $data);
 }
 /**
  * User chose single employee from dropdown to be edited
  *
  * @param Request $request
  * @return mixed
  */
 public function doChooseEmployee(Request $request)
 {
     $employee = Employee::find($request->input('choose'));
     $dept = ['' => 'Choose...'] + Department::lists('name', 'id')->all();
     $location = ['' => 'Choose...'] + Location::lists('name', 'id')->all();
     return view('admin.edit-employee', compact('dept', 'location', 'employee'));
 }
 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;
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('locations')->delete();
     Location::create(['location_id' => '0', 'location' => 'National', 'abbrev' => 'National']);
     Location::create(['location_id' => '1', 'location' => 'Texas', 'abbrev' => 'TX']);
     Location::create(['location_id' => '2', 'location' => 'Alabama', 'abbrev' => 'AL']);
     Location::create(['location_id' => '3', 'location' => 'Alaska', 'abbrev' => 'AK']);
     Location::create(['location_id' => '4', 'location' => 'Arizona', 'abbrev' => 'AZ']);
     Location::create(['location_id' => '5', 'location' => 'Arkansas', 'abbrev' => 'AR']);
     Location::create(['location_id' => '384', 'location' => 'Armed Forces Americas', 'abbrev' => 'AA']);
     Location::create(['location_id' => '385', 'location' => 'Armed Forces Europe', 'abbrev' => 'AE']);
     Location::create(['location_id' => '386', 'location' => 'Armed Forces Pacific', 'abbrev' => 'AP']);
     Location::create(['location_id' => '6', 'location' => 'California', 'abbrev' => 'CA']);
     Location::create(['location_id' => '7', 'location' => 'Colorado', 'abbrev' => 'CO']);
     Location::create(['location_id' => '8', 'location' => 'Connecticut', 'abbrev' => 'CT']);
     Location::create(['location_id' => '10', 'location' => 'Delaware', 'abbrev' => 'DE']);
     Location::create(['location_id' => '9', 'location' => 'District of Columbia', 'abbrev' => 'CO']);
     Location::create(['location_id' => '11', 'location' => 'Florida', 'abbrev' => 'FL']);
     Location::create(['location_id' => '12', 'location' => 'Georgia', 'abbrev' => 'GA']);
     Location::create(['location_id' => '14', 'location' => 'Hawaii', 'abbrev' => 'HI']);
     Location::create(['location_id' => '15', 'location' => 'Idaho', 'abbrev' => 'ID']);
     Location::create(['location_id' => '17', 'location' => 'Illinois', 'abbrev' => 'IL']);
     Location::create(['location_id' => '18', 'location' => 'Indiana', 'abbrev' => 'IN']);
     Location::create(['location_id' => '16', 'location' => 'Iowa', 'abbrev' => 'IA']);
     Location::create(['location_id' => '19', 'location' => 'Kansas', 'abbrev' => 'KS']);
     Location::create(['location_id' => '20', 'location' => 'Kentucky', 'abbrev' => 'KY']);
     Location::create(['location_id' => '21', 'location' => 'Louisiana', 'abbrev' => 'LA']);
     Location::create(['location_id' => '22', 'location' => 'Maine', 'abbrev' => 'ME']);
     Location::create(['location_id' => '23', 'location' => 'Maryland', 'abbrev' => 'MD']);
     Location::create(['location_id' => '24', 'location' => 'Massachusetts', 'abbrev' => 'MA']);
     Location::create(['location_id' => '25', 'location' => 'Michigan', 'abbrev' => 'MI']);
     Location::create(['location_id' => '26', 'location' => 'Minnesota', 'abbrev' => 'MN']);
     Location::create(['location_id' => '27', 'location' => 'Mississippi', 'abbrev' => 'MS']);
     Location::create(['location_id' => '28', 'location' => 'Missouri', 'abbrev' => 'MO']);
     Location::create(['location_id' => '29', 'location' => 'Montana', 'abbrev' => 'ME']);
     Location::create(['location_id' => '30', 'location' => 'Nebraska', 'abbrev' => 'NE']);
     Location::create(['location_id' => '31', 'location' => 'Nevada', 'abbrev' => 'NE']);
     Location::create(['location_id' => '32', 'location' => 'New Hampshire', 'abbrev' => 'NH']);
     Location::create(['location_id' => '33', 'location' => 'New Jersey', 'abbrev' => 'NJ']);
     Location::create(['location_id' => '34', 'location' => 'New Mexico', 'abbrev' => 'MM']);
     Location::create(['location_id' => '35', 'location' => 'New York', 'abbrev' => 'NY']);
     Location::create(['location_id' => '36', 'location' => 'North Carolina', 'abbrev' => 'NC']);
     Location::create(['location_id' => '37', 'location' => 'North Dakota', 'abbrev' => 'ND']);
     Location::create(['location_id' => '38', 'location' => 'Ohio', 'abbrev' => 'OH']);
     Location::create(['location_id' => '39', 'location' => 'Oklahoma', 'abbrev' => 'OK']);
     Location::create(['location_id' => '40', 'location' => 'Oregon', 'abbrev' => 'OR']);
     Location::create(['location_id' => '41', 'location' => 'Pennsylvania', 'abbrev' => 'PA']);
     Location::create(['location_id' => '42', 'location' => 'Rhoda Island', 'abbrev' => 'RI']);
     Location::create(['location_id' => '43', 'location' => 'South Carolina', 'abbrev' => 'SC']);
     Location::create(['location_id' => '44', 'location' => 'South Dakota', 'abbrev' => 'SD']);
     Location::create(['location_id' => '45', 'location' => 'Tennessee', 'abbrev' => 'TN']);
     Location::create(['location_id' => '46', 'location' => 'Utah', 'abbrev' => 'UT']);
     Location::create(['location_id' => '47', 'location' => 'Vermont', 'abbrev' => 'VT']);
     Location::create(['location_id' => '48', 'location' => 'Virginia', 'abbrev' => 'VA']);
     Location::create(['location_id' => '49', 'location' => 'Washington', 'abbrev' => 'WA']);
     Location::create(['location_id' => '50', 'location' => 'West Virginia', 'abbrev' => 'WV']);
     Location::create(['location_id' => '51', 'location' => 'Wisconson', 'abbrev' => 'WI']);
     Location::create(['location_id' => '52', 'location' => 'Wyoming', 'abbrev' => 'WY']);
 }
예제 #24
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $location = Location::findOrFail($id);
     $weathers = Weather::get($location->name);
     $hospitals = Hospital::where('address', 'LIKE', "%{$location->name}%")->get();
     $request = ['weathers' => $weathers, 'hospitals' => $hospitals];
     return json_encode($request);
 }
예제 #25
0
 public function run()
 {
     DB::table('locations')->delete();
     $locations = [['location' => 'Corporate', 'loc_abr' => 'ARM', 'address' => '2222 South Louisa Street', 'city' => 'Rayville', 'state' => 'LA', 'zip' => '71269', 'phone' => '3187285770', 'manager_id' => 5, 'region_id' => 1], ['location' => 'ARM MS', 'loc_abr' => 'CLE', 'address' => '201 E. Sunflower Road, Suite 10', 'city' => 'Cleveland', 'state' => 'MS', 'zip' => '38732', 'phone' => '6628430944', 'manager_id' => 6, 'region_id' => 2], ['location' => 'ARM Crowley', 'loc_abr' => 'CRO', 'address' => '121 East Fifth Street', 'city' => 'Crowley', 'state' => 'LA', 'zip' => '70526', 'phone' => '3372504488', 'manager_id' => 6, 'region_id' => 3], ['location' => 'ARM Jonesboro', 'loc_abr' => 'JON', 'address' => '2524 Alexander Drive, Suite D', 'city' => 'Jonesboro', 'state' => 'AR', 'zip' => '72401', 'phone' => '8703362620', 'manager_id' => 6, 'region_id' => 3], ['location' => 'ARM Rayville', 'loc_abr' => 'RAY', 'address' => '2222 Louisa Street', 'city' => 'Rayville', 'state' => 'LA', 'zip' => '71269', 'phone' => '3187285770', 'manager_id' => 7, 'region_id' => 3], ['location' => 'ARM Dexter', 'loc_abr' => 'DEX', 'address' => '325 W Business US 60', 'city' => 'Dexter', 'state' => 'MO', 'zip' => '63841', 'phone' => '5738914101', 'manager_id' => 6, 'region_id' => 3], ['location' => 'ARM Amarillo', 'loc_abr' => 'AMA', 'address' => '7116 Interstate Hwy 40 Bldg C, Ste B', 'city' => 'Amarillo', 'state' => 'TX', 'zip' => '79106', 'phone' => '8065532918', 'manager_id' => 6, 'region_id' => 3], ['location' => 'ARM Victoria', 'loc_abr' => 'VIC', 'address' => '108 E Forrest', 'city' => 'Victoria', 'state' => 'TX', 'zip' => '77901', 'phone' => '3612371717', 'manager_id' => 6, 'region_id' => 3]];
     foreach ($locations as $location) {
         Location::create($location);
     }
 }
예제 #26
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $state = \Input::get('state');
     $county = \Input::get('county');
     $location = \App\Location::with('products')->where(['state' => $state, 'county' => $county])->firstOrFail();
     $products = $location->products;
     return view('products.index', compact('location', 'products'));
 }
예제 #27
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Location::firstOrCreate(['name' => "1 Yellow Brick Road, Cork City, Cork", 'latitude' => 51.898202, 'longitude' => -8.479321000000001, 'capacity' => "200", 'featured_image' => '/images/sample_images/venues/1.jpg']);
     Location::firstOrCreate(['name' => "2 Yellow Brick Road, Cork City, Cork", 'latitude' => 52, 'longitude' => -9.479321000000001, 'capacity' => "200", 'featured_image' => '/images/sample_images/venues/1.jpg']);
     Location::firstOrCreate(['name' => "3 Yellow Brick Road, Cork City, Cork", 'latitude' => 51.7, 'longitude' => -8.5, 'capacity' => "200", 'featured_image' => '/images/sample_images/venues/1.jpg']);
     Location::firstOrCreate(['name' => "4 Yellow Brick Road, Cork City, Cork", 'latitude' => 51.6, 'longitude' => -8.579321, 'capacity' => "200", 'featured_image' => '/images/sample_images/venues/1.jpg']);
     Location::firstOrCreate(['name' => "5 Yellow Brick Road, Cork City, Cork", 'latitude' => 51.998202, 'longitude' => -8.779320999999999, 'capacity' => "200", 'featured_image' => '/images/sample_images/venues/1.jpg']);
 }
예제 #28
0
 public function newPosts(Request $request)
 {
     $lattitude = $request->input('lattitude');
     $longitude = $request->input('longitude');
     $radius = 10;
     $posts = Location::select(DB::raw("locations.post_id,\n                               ( 6371 * acos( cos( radians(?) ) *\n                                 cos( radians( lattitude ) )\n                                 * cos( radians( longitude ) - radians(?)\n                                 ) + sin( radians(?) ) *\n                                 sin( radians( lattitude ) ) )\n                               ) AS distance, posts.message, posts.user_id, users.id, users.name, users.user_name"))->join('posts', 'posts.id', '=', 'locations.post_id')->join('users', 'users.id', '=', 'posts.user_id')->having("distance", "<", $radius)->orderBy("posts.created_at", 'desc')->setBindings([$lattitude, $longitude, $lattitude])->distinct()->get();
     return response()->json($posts);
 }
 public function postDeleteLocation(Request $request)
 {
     $locationId = intval($request->input('location_id'));
     if ($locationId) {
         Location::find($locationId)->delete();
         return response(Location::all());
     }
     return redirect('dashboard/locations')->withErrors('No location id passed');
 }
 public function destroy($id)
 {
     $location = Location::find($id);
     if ($location->delete()) {
         return $this->output('Location deleted');
     } else {
         return $this->notFound('Location not found');
     }
 }