当前位置: 首页>>代码示例>>PHP>>正文


PHP Location::where方法代码示例

本文整理汇总了PHP中Location::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Location::where方法的具体用法?PHP Location::where怎么用?PHP Location::where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Location的用法示例。


在下文中一共展示了Location::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 public function run()
 {
     $row = 1;
     if (($handle = fopen(storage_path() . "/csvs/breweries.csv", "r")) !== FALSE) {
         while (($data = fgetcsv($handle)) !== FALSE) {
             $zip = $data[6];
             // echo $zip . PHP_EOL;
             try {
                 // echo Location::where('postalCode',$zip)->toSql();
                 $loc = Location::where('postalCode', $zip)->firstOrFail();
                 $locId = $loc->locId;
                 $brewery = new Brewery();
                 $brewery->brewery_id = $data[0];
                 $brewery->name = $data[1];
                 $brewery->address = $data[2];
                 $brewery->phone = $data[8];
                 $brewery->website = $data[9];
                 $brewery->description = $data[11];
                 $brewery->locId = $locId;
                 $brewery->save();
             } catch (Exception $e) {
                 // echo $e->getMessage();
                 // throw $e;
             }
         }
         fclose($handle);
     } else {
         echo 'false?';
     }
 }
开发者ID:hopshoppub,项目名称:hopshop.dev,代码行数:30,代码来源:BreweriesTableSeeder.php

示例2: fire

 /**
  * Execute the console command.
  *
  *	@todo  DON'T UPDATE LOCATIONS IF THEY'RE ALREADY SET
  *
  * @return mixed
  */
 public function fire()
 {
     $Bodmin = Area::firstOrCreate(['name' => 'Bodmin']);
     // Ensure current locations are saved.
     foreach (array_unique(Interview::where('location_id', '=', '')->lists('location')) as $location) {
         if (strlen($location) === 0) {
             continue;
             // don't want to clobber real locations
         }
         $L = Location::firstOrNew(['name' => $location]);
         if ($L->exists) {
             continue;
         }
         $L->area()->associate($Bodmin);
         $L->save();
     }
     Interview::all()->each(function ($Interview) {
         $Location = Location::where('name', '=', $Interview->location);
         if ($Location->count() <= 0) {
             \Log::error("This location not found despite having just been confirmed a few lines above", $Interview->toArray());
             return;
         }
         $Interview->location_id = $Location->first()->id;
         $Interview->save();
     });
 }
开发者ID:mymedialab,项目名称:listenings,代码行数:33,代码来源:MigrateLocations.php

示例3: searchCities

 public function searchCities($key)
 {
     //$key = $_REQUEST['term'];
     if (isset($key)) {
         $locations = Location::where('city', 'like', '%' . $key . '%')->get();
         if (isset($locations) && count($locations) > 0) {
             return json_encode(array('message' => 'found', 'locations' => $locations->toArray()));
         } else {
             return json_encode(array('message' => 'empty'));
         }
     } else {
         return json_encode(array('message' => 'invalid'));
     }
 }
开发者ID:ashutoshpandey,项目名称:course,代码行数:14,代码来源:SearchController.php

示例4: allLocationsByVendor

 public function allLocationsByVendor()
 {
     if (isset($_GET['vendor_id'])) {
         if (sizeof(Vendor::find($_GET['vendor_id'])) == 1) {
             $data = array('status' => 'ok', 'locations' => Location::where('vendor_id', '=', $_GET['vendor_id'])->get());
             return $data;
         } else {
             $data = array('status' => 'failed', 'error_msg' => 'Vendor specified does not exist');
             return $data;
         }
     } else {
         $data = array('status' => 'failed', 'error_msg' => 'Vendor ID was not specified');
         return $data;
     }
 }
开发者ID:GeorgeBroadley,项目名称:caffeine-vendor,代码行数:15,代码来源:ApiController.php

示例5: create

 public function create()
 {
     $menu = 'registration';
     $generations = Generation::all();
     $classifications = Classification::where('category', '=', 'Registration')->get();
     $locations = Location::where('id', '<>', Auth::user()->location_id)->get();
     $employees = Employee::all();
     $courses = Course::where('project_id', '=', Auth::user()->curr_project_id)->where('location_id', '=', Auth::user()->location_id)->where('availability', '=', 1)->where('active', '=', 1)->get();
     $discounts = Discount::all();
     $promotions = Promotion::all();
     $vouchers = Voucher::all();
     $charges = Charge::all();
     $partners = Partner::where('location_id', '=', Auth::user()->location_id)->get();
     return View::make('registrations.create', compact('classifications', 'locations', 'employees', 'generations', 'courses', 'charges', 'discounts', 'promotions', 'vouchers', 'partners', 'menu'));
 }
开发者ID:emanmks,项目名称:oneschool,代码行数:15,代码来源:RegistrationsController.php

示例6: getCities

 public function getCities($state)
 {
     $adminId = Session::get('admin_id');
     if (!isset($adminId)) {
         return json_encode(array('message' => 'not logged'));
     }
     if (isset($state)) {
         $locations = Location::where('state', '=', $state)->where('status', '=', 'active')->get();
         if (isset($locations) && count($locations) > 0) {
             return json_encode(array('message' => 'found', 'locations' => $locations->toArray()));
         } else {
             return json_encode(array('message' => 'empty'));
         }
     } else {
         return json_encode(array('message' => 'invalid'));
     }
 }
开发者ID:ashutoshpandey,项目名称:dicom,代码行数:17,代码来源:LocationController.php

示例7: getNearbyUsers

 private function getNearbyUsers($latitude, $longitude, $distance, $userId)
 {
     $locations = Location::where('updated_at', '>', date("Y-m-d H:i:s", time() - self::LAST_ACTIVE_THRESHOLD_IN_SECONDS))->with("user", "user.contact", "user.bodyInformation")->get();
     if ($locations->isEmpty()) {
         return Response::json(array("status" => "ok", "users" => array(), "msg" => "No users recently active in your area."));
     }
     $users = array();
     foreach ($locations as $location) {
         if ($location->user_id == $userId) {
             continue;
         }
         $distanceFromUser = Distances::distanceInMiles($latitude, $longitude, $location->latitude, $location->longitude);
         if ($distanceFromUser <= $distance) {
             $location['distance'] = $distanceFromUser;
             array_push($users, $location);
         }
     }
     return Response::json(array("status" => "ok", "users" => $users, "msg" => "This is all the active users near you right now!"));
 }
开发者ID:samuraiseoul,项目名称:f.it,代码行数:19,代码来源:AppController.php

示例8: change

 public function change()
 {
     $this->layout->body_class = 'home';
     $zip_code = Input::get('zip_code', '');
     $distance = Input::get('distance', '50');
     Session::put('zip_code', $zip_code);
     Session::put('distance', $distance);
     $location_info = 'change location';
     if (!empty($zip_code)) {
         $locations = Location::where('zip_code', '=', $zip_code);
         if ($locations->count()) {
             $location = Location::where('zip_code', '=', $zip_code)->first();
             $city = $location->city;
             $state = $location->state;
             if (!empty($city) && !empty($state)) {
                 $location_info = $distance . ' miles from ' . $city . ', ' . $state . ' (change)';
             }
         }
     }
     $data = array('zip_code' => $zip_code, 'distance' => $distance, 'location_info' => $location_info);
     $this->layout->contents = View::make('home/home', $data);
 }
开发者ID:apetrailmukesh,项目名称:bootstrap,代码行数:22,代码来源:HomeController.php

示例9: fire


//.........这里部分代码省略.........
             $user_email_array = User::generateFormattedNameFromFullName($this->option('email_format'), $user_name);
             $first_name = $user_email_array['first_name'];
             $last_name = $user_email_array['last_name'];
             if ($user_email == '') {
                 $user_email = $user_email_array['username'] . '@' . Config::get('app.domain');
             }
             if ($user_username == '') {
                 if ($this->option('username_format') == 'email') {
                     $user_username = $user_email;
                 } else {
                     $user_name_array = User::generateFormattedNameFromFullName($this->option('username_format'), $user_name);
                     $user_username = $user_name_array['username'];
                 }
             }
         }
         $this->comment('Full Name: ' . $user_name);
         $this->comment('First Name: ' . $first_name);
         $this->comment('Last Name: ' . $last_name);
         $this->comment('Username: ' . $user_username);
         $this->comment('Email: ' . $user_email);
         $this->comment('Category Name: ' . $user_asset_category);
         $this->comment('Item: ' . $user_asset_name);
         $this->comment('Manufacturer ID: ' . $user_asset_mfgr);
         $this->comment('Model No: ' . $user_asset_modelno);
         $this->comment('Serial No: ' . $user_asset_serial);
         $this->comment('Asset Tag: ' . $user_asset_tag);
         $this->comment('Location: ' . $user_asset_location);
         $this->comment('Purchase Date: ' . $user_asset_purchase_date);
         $this->comment('Purchase Cost: ' . $user_asset_purchase_cost);
         $this->comment('Notes: ' . $user_asset_notes);
         $this->comment('Company Name: ' . $user_asset_company_name);
         $this->comment('------------- Action Summary ----------------');
         if ($user_username != '') {
             if ($user = User::MatchEmailOrUsername($user_username, $user_email)->whereNotNull('username')->first()) {
                 $this->comment('User ' . $user_username . ' already exists');
             } else {
                 // Create the user
                 $user = Sentry::createUser(array('first_name' => $first_name, 'last_name' => $last_name, 'email' => $user_email, 'username' => $user_username, 'password' => substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 12), 'activated' => true, 'permissions' => array('admin' => 0, 'user' => 1), 'notes' => 'User imported through asset importer'));
                 // Find the group using the group id
                 $userGroup = Sentry::findGroupById(3);
                 // Assign the group to the user
                 $user->addGroup($userGroup);
                 $this->comment('User ' . $first_name . ' created');
             }
         } else {
             $user = new User();
         }
         // Check for the location match and create it if it doesn't exist
         if ($location = Location::where('name', e($user_asset_location))->first()) {
             $this->comment('Location ' . $user_asset_location . ' already exists');
         } else {
             $location = new Location();
             if ($user_asset_location != '') {
                 $location->name = e($user_asset_location);
                 $location->address = '';
                 $location->city = '';
                 $location->state = '';
                 $location->country = '';
                 $location->user_id = 1;
                 if (!$this->option('testrun') == 'true') {
                     if ($location->save()) {
                         $this->comment('Location ' . $user_asset_location . ' was created');
                     } else {
                         $this->comment('Something went wrong! Location ' . $user_asset_location . ' was NOT created');
                     }
                 } else {
开发者ID:cralle,项目名称:snipe-it,代码行数:67,代码来源:AssetImportCommand.php

示例10: buildFilterQuery

 public function buildFilterQuery($exclude)
 {
     $and = array();
     $zip_code = Input::query('zip_code', '');
     $distance = Input::query('distance', '50');
     if (!empty($zip_code) && !empty($distance)) {
         $locations = Location::where('zip_code', '=', $zip_code);
         if ($locations->count()) {
             $location = Location::where('zip_code', '=', $zip_code)->first();
             $latitude = $location->latitude;
             $longitude = $location->longitude;
             $distance = $distance * 1.609344 . 'km';
             array_push($and, array("geo_distance" => array("pin.location" => array("lat" => $latitude, "lon" => $longitude), "distance" => $distance)));
         }
     }
     if ($exclude != 'make') {
         $and = $this->utility_make->buildFilterQuery($and, Input::get('make', ''));
     }
     if ($exclude != 'model') {
         $and = $this->utility_model->buildFilterQuery($and, Input::get('model', ''));
     }
     if ($exclude != 'price') {
         $and = $this->utility_price->buildFilterQuery($and, Input::get('price', ''));
         $and = $this->utility_price->buildCustomFilterQuery($and, Input::get('price-custom', ''));
     }
     if ($exclude != 'mileage') {
         $and = $this->utility_mileage->buildFilterQuery($and, Input::get('mileage', ''));
         $and = $this->utility_mileage->buildCustomFilterQuery($and, Input::get('mileage-custom', ''));
     }
     if ($exclude != 'photo') {
         $and = $this->utility_photo->buildFilterQuery($and, Input::get('photo', ''));
     }
     if ($exclude != 'transmission') {
         $and = $this->utility_transmission->buildFilterQuery($and, Input::get('transmission', ''));
     }
     if ($exclude != 'year') {
         $and = $this->utility_year->buildFilterQuery($and, Input::get('year', ''));
         $and = $this->utility_year->buildCustomFilterQuery($and, Input::get('year-custom', ''));
     }
     if ($exclude != 'status') {
         $and = $this->utility_status->buildFilterQuery($and, Input::get('status', ''));
     }
     if ($exclude != 'body') {
         $and = $this->utility_body->buildFilterQuery($and, Input::get('body', ''));
     }
     if ($exclude != 'certified') {
         $and = $this->utility_certified->buildFilterQuery($and, Input::get('certified', ''));
     }
     if ($exclude != 'doors') {
         $and = $this->utility_doors->buildFilterQuery($and, Input::get('doors', ''));
     }
     if ($exclude != 'cylinders') {
         $and = $this->utility_cylinders->buildFilterQuery($and, Input::get('cylinders', ''));
     }
     if ($exclude != 'fuel') {
         $and = $this->utility_fuel->buildFilterQuery($and, Input::get('fuel', ''));
     }
     if ($exclude != 'drive') {
         $and = $this->utility_drive->buildFilterQuery($and, Input::get('drive', ''));
     }
     if ($exclude != 'interior') {
         $and = $this->utility_interior->buildFilterQuery($and, Input::get('interior', ''));
     }
     if ($exclude != 'exterior') {
         $and = $this->utility_exterior->buildFilterQuery($and, Input::get('exterior', ''));
     }
     $filter = array();
     if (sizeof($and) > 0) {
         $filter['and'] = $and;
         return $filter;
     } else {
         return false;
     }
 }
开发者ID:apetrailmukesh,项目名称:bootstrap,代码行数:74,代码来源:SearchController.php

示例11: getLocationBySeasonId

 public function getLocationBySeasonId()
 {
     $inputs = Input::all();
     $location_data = Location::where('season_id', '=', $inputs['seasonId'])->get();
     return Response::json(array('status' => 'success', 'data' => $location_data));
 }
开发者ID:Headrun-php,项目名称:TLG,代码行数:6,代码来源:SeasonsController.php

示例12: getLocationBySeasonId

 public static function getLocationBySeasonId($seasonId)
 {
     return Location::where('season_id', '=', $seasonId)->get();
 }
开发者ID:Headrun-php,项目名称:TLG,代码行数:4,代码来源:Location.php

示例13: stateCity

 public function stateCity($id)
 {
     $this->layout->body_class = '';
     $state = null;
     foreach ($this->getStates() as $entity) {
         if (explode("-", $id)[0] == $entity['code']) {
             $state = $entity;
             break;
         }
     }
     $columns = array(array(), array(), array());
     $cities = DB::select(DB::raw("SELECT DISTINCT city FROM vehicle WHERE state = :state ORDER BY city"), array('state' => $state['code']));
     foreach ($cities as $key => $value) {
         $location = Location::where('state', '=', $state['code'])->where('city', '=', $value->city);
         if ($location->count()) {
             $zip = $location->first()->zip_code;
             $link = '/search?zip_code=' . $zip . '&distance=50&page=1&sort=price-1';
             $title = 'Cars for sale near ' . $value->city . ', ' . $state['code'];
             $city = array('link' => $link, 'title' => $title);
             array_push($columns[$key % 3], $city);
         }
     }
     $data = array('search_text' => '', 'state' => $state, 'columns' => $columns);
     $this->layout->contents = View::make('browse/state-city', $data);
 }
开发者ID:apetrailmukesh,项目名称:bootstrap,代码行数:25,代码来源:BrowseController.php

示例14: geelong

 public function geelong()
 {
     $locations = Location::where('name', '=', 'geelong')->get();
     return View::make('locations.geelong', compact('locations'));
 }
开发者ID:shankargiri,项目名称:taylor_latest,代码行数:5,代码来源:LocationsController.php

示例15: withinDistance

 /**
  * Calcuate the number of physicians within a certain number of 
  * miles of a ZIP code.
  *
  * @param string
  * @return string
  */
 public function withinDistance(Request $request)
 {
     if (!$request->has(['miles', 'zip'])) {
         app()->abort(404);
     }
     $location = Location::where('zip', '=', $request->zip)->get();
     $lat = $location[0]->lat;
     $lon = $location[0]->lon;
     //$haversineSelectStmt =
     //$this->haversineSelect($lat, $lon);
     //$physicians = Physician::select(DB::raw($haversineSelectStmt))
     //->having('distance', '<', $request->miles)
     //->orderBy('distance', 'asc')
     //->get();
     $physicians = Physician::withinRadius($lat, $lon, $searchDistance)->orderBy('distance', 'asc')->paginate($limit);
     $count = (string) count($physicians);
     return json_encode(['count' => $count]);
 }
开发者ID:pjsinco,项目名称:lookup-api,代码行数:25,代码来源:PhysicianController.php


注:本文中的Location::where方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。