本文整理汇总了PHP中app\models\Location::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Location::where方法的具体用法?PHP Location::where怎么用?PHP Location::where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Location
的用法示例。
在下文中一共展示了Location::where方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: locations
public function locations($state_id, $city_key)
{
$city = City::where("estado_id", $state_id)->where("clave", $city_key)->first();
$locations = Location::where("municipio_id", $city->id)->get();
return response()->json($locations)->header('Access-Control-Allow-Origin', '*');
}
示例2: result
function result($id)
{
$blueprint = Blueprint::with(["questions.options"])->find($id);
$test = function ($question_type, $inegi_key) {
if (!$inegi_key) {
return "-";
}
switch ($question_type) {
case "location-a":
$key = substr($inegi_key->text_value, 0, 2);
$name = !empty($key) ? $this->states[$key] : "-";
break;
case "location-b":
$state_key = substr($inegi_key->text_value, 0, 2);
$state_name = !empty($state_key) ? $this->states[$state_key] : "-";
$city_key = substr($inegi_key->text_value, 2, 3);
$city = !empty($city_key) ? City::where("clave", $city_key)->where("estado_id", (int) $state_key)->first() : null;
$city_name = $city ? $city->nombre : "-";
$name = $city_name . ", " . $state_name;
break;
case "location-c":
$state_key = substr($inegi_key->text_value, 0, 2);
$state_name = !empty((int) $state_key) ? $this->states[$state_key] : "-";
$city_key = substr($inegi_key->text_value, 2, 3);
$city = !empty($city_key) ? City::where("clave", $city_key)->where("estado_id", (int) $state_key)->first() : null;
$city_name = $city ? $city->nombre : "-";
$location_key = substr($inegi_key->text_value, 5, 4);
$location = !empty((int) $location_key) ? Location::where("clave", $location_key)->where("municipio_id", $city->id)->first() : null;
$location_name = $location ? $location->nombre : "-";
$name = $location_name . ", " . $city_name . ", " . $state_name;
break;
default:
$name = "-";
break;
}
return $name;
};
if (!$blueprint) {
die("Este formulario no existe!");
}
$data = [];
$data['blueprint'] = $blueprint;
$data['title'] = 'Resultados | Tú Evalúas';
$data['description'] = 'Resultados de cuestionarios en Tú Evalúas';
$data['body_class'] = 'results';
$data['test'] = $test;
return view("frontend.result_survey")->with($data);
}
示例3: listLocations
public function listLocations($id)
{
return Location::where('company_id', $id)->get();
}
示例4: 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('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 {
$user = new \App\Models\User();
$password = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 20);
$user->first_name = $first_name;
$user->last_name = $last_name;
$user->username = $user_username;
$user->email = $user_email;
$user->permissions = '{user":1}';
$user->password = bcrypt($password);
$user->activated = 1;
if ($user->save()) {
$this->comment('User ' . $first_name . ' created');
} else {
$this->error('ERROR CREATING User ' . $first_name . ' ' . $last_name);
$this->error($user->getErrors());
}
}
} 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 = '';
示例5: handle
//.........这里部分代码省略.........
foreach ($requiredFieldsCommands as $field => $command) {
try {
$offer->{$field} = $command();
} catch (\Exception $e) {
$logger->error('Unable to extract required fields', self::arrayInsert($context, 'required_field', $field));
throw $e;
}
}
$fieldsCommands = ['price_string' => function () use($crawler) {
return $crawler->filter('.pricelabel.tcenter')->first()->text();
}, 'title' => function () use($crawler) {
return $crawler->filter('.offerheadinner > h1')->text();
}, 'olx_id' => function () {
return self::getOlxId($this->url->url);
}, 'description' => function () use($crawler) {
return $crawler->filter('#textContent')->text();
}, 'date_string' => function () use($crawler) {
return self::getDate($crawler);
}, 'offer_number' => function () use($crawler) {
return self::getOfferNumber($crawler);
}];
$failedFields = [];
foreach ($fieldsCommands as $field => $command) {
try {
$offer->{$field} = trim($command());
} catch (\Exception $e) {
array_push($failedFields, $field);
}
}
$detailsTables = $crawler->filter('table.details table.item');
$details = [];
foreach ($detailsTables as $detailsTable) {
/** @var $detailsTable Crawler */
try {
$details[$detailsTable->getElementsByTagName('th')->item(0)->textContent] = preg_replace('/\\t*|\\n*|\\s{2,}/u', '', $detailsTable->getElementsByTagName('td')->item(0)->textContent);
} catch (\Exception $e) {
array_push($failedFields, $detailsTable->text());
}
}
if ($details) {
$offer->details = $details;
}
if ($failedFields and $failedFields !== ["price_string"]) {
// lots of offers don't have assigned price
$logger->warning('Failed fields', self::arrayInsert($context, 'failed_fields', $failedFields));
}
if ($olxTimestamp = self::parseDate($offer->date_string)) {
$offer->created_at_olx = $olxTimestamp;
}
try {
$offer->save();
} catch (QueryException $e) {
if (23000 === intval($e->getCode())) {
return;
// duplicate offer, finish job
}
$logger->error('', self::arrayInsert($context, 'exception', $e));
throw $e;
}
if ($offer) {
try {
$detectPhones = new DetectPhones($offer);
$detectPhones->handle();
} catch (\Exception $e) {
\Log::critical('Failed to detect phones', ['exception' => $e]);
}
}
if ($offer->wasRecentlyCreated) {
$photos = [];
try {
$photos = $crawler->filter('#bigGallery a')->reduce(function (Crawler $node, $i) {
return (bool) $node->attr('href');
})->extract('href');
} catch (Exception $e) {
$logger->error('Failed to get photos', self::arrayInsert($context, 'exception', $e));
}
if ($photos) {
foreach ($photos as $photo) {
$offer->photos()->create(['url' => $photo]);
}
}
if ($locationString = self::getLocationString($crawler)) {
if ($location = Location::where('location', $locationString)->first()) {
$offer->location()->associate($location);
$offer->save();
} else {
try {
$location = Location::create(['location' => $locationString]);
} catch (QueryException $e) {
$logger->error('Unable to create Location', self::arrayInsert($context, 'location', $locationString));
}
if ($location instanceof Location) {
$offer->location()->associate($location);
$offer->save();
}
}
}
}
Event::fire(new OfferParsed($offer));
}
示例6: find_location
private function find_location($question_type, $inegi_key)
{
if (!$inegi_key) {
return "-";
}
switch ($question_type) {
case "location-a":
$key = substr($inegi_key->text_value, 0, 2);
$name = !empty($key) ? $this->states[$key] : "-";
break;
case "location-b":
$state_key = substr($inegi_key->text_value, 0, 2);
$state_name = !empty($state_key) ? $this->states[$state_key] : "-";
$city_key = substr($inegi_key->text_value, 2, 3);
$city = !empty($city_key) ? City::where("clave", $city_key)->where("estado_id", (int) $state_key)->first() : null;
$city_name = $city ? $city->nombre : "-";
$name = $city_name . ", " . $state_name;
break;
case "location-c":
$state_key = substr($inegi_key->text_value, 0, 2);
$state_name = !empty($state_key) ? $this->states[$state_key] : "-";
$city_key = substr($inegi_key->text_value, 2, 3);
$city = !empty($city_key) ? City::where("clave", $city_key)->where("estado_id", (int) $state_key)->first() : null;
$city_name = $city ? $city->nombre : "-";
$location_key = substr($inegi_key->text_value, 5, 4);
$location = !empty($location_key) ? Location::where("clave", $location_key)->where("municipio_id", $city->id)->first() : null;
$location_name = $location ? $location->nombre : "-";
$name = $location_name . ", " . $city_name . ", " . $state_name;
break;
default:
$name = "-";
break;
}
return $name;
}