本文整理汇总了PHP中app\models\Region::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Region::where方法的具体用法?PHP Region::where怎么用?PHP Region::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Region
的用法示例。
在下文中一共展示了Region::where方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
// Suppression de la table 'terrains' de la base de données
DB::table('terrains')->delete();
// Chargement de la liste des sports existants
$sports = Sport::all();
// Création d'une liste de valeurs par défaut
$items = [["Football 1 Cégep de Drummondville", "960 Rue Saint-Georges", "Drummondville", [0, 1, 2]], ["Football 2 Cégep de Drummondville", "960 Rue Saint-Georges", "Drummondville", [0, 1, 2]], ["Football 3 Cégep de Drummondville", "960 Rue Saint-Georges", "Drummondville", [0, 1, 2]], ["Soccer 1 Cégep de Drummondville", "960 Rue Saint-Georges", "Drummondville", [0, 1, 2]], ["Soccer 2 Cégep de Drummondville", "960 Rue Saint-Georges", "Drummondville", [0, 1, 2]], ["Football 1 Marie-Rivier", "265 Rue Saint Félix", "Drummondville", [0, 1, 2]], ["Football 2 Marie-Rivier", "265 Rue Saint Félix", "Drummondville", [0, 1, 2]], ["Football 3 Marie-Rivier", "265 Rue Saint Félix", "Drummondville", [0, 1, 2]], ["Soccer 1 Marie-Rivier", "265 Rue Saint Félix", "Drummondville", [0, 1, 2]], ["Soccer 2 Marie-Rivier", "265 Rue Saint Félix", "Drummondville", [0, 1, 2]], ["Football 1 Jean-Raimbault", "175 Rue Pelletier", "Drummondville", [0, 1, 2]], ["Football 2 Jean-Raimbault", "175 Rue Pelletier", "Drummondville", [0, 1, 2]], ["Football 3 Jean-Raimbault", "175 Rue Pelletier", "Drummondville", [0, 1, 2]], ["Soccer 1 Jean-Raimbault", "175 Rue Pelletier", "Drummondville", [0, 1, 2]], ["Soccer 2 Jean-Raimbault", "177 Rue Pelletier", "Drummondville", [0, 1, 2]]];
// Création d'objet 'terrain' et sauvegarde de ceux-ci dans la base de données
foreach ($items as $item) {
$terrain = new Terrain();
$terrain->nom = $item[0];
$terrain->adresse = $item[1];
$terrain->ville = $item[2];
$terrain->region_id = Region::where("nom_court", "=", "CDQ")->first()->id;
//un peu de favoritisme pour le Centre du Québec.
$terrain->save();
// Ajout de l'association entre les terrains et les sports
$index_sports = array();
for ($x = 0; $x < count($item[3]); $x++) {
array_push($index_sports, $sports[$x]->id);
}
$terrain->sports()->sync($index_sports);
}
}
示例2: run
public function run()
{
ini_set('max_execution_time', 0);
//300 seconds = 5 minutes
DB::table('areas')->delete();
DB::table('towns')->delete();
$regions = $this->api('database.getRegions', ['country_id' => 2]);
foreach ($regions['response'] as $region) {
$towns = $this->api('database.getCities', ['country_id' => 2, 'region_id' => $region['region_id'], 'count' => 1000]);
foreach ($towns['response'] as $town) {
$area = Area::firstOrCreate(['name' => isset($town['area']) ? $town['area'] : $town['title'], 'region_id' => isset(Region::where('name', '=', $town['region'])->first()->id) ? Region::where('name', '=', $town['region'])->first()->id : 0]);
Town::create(['name' => $town['title'], 'area_id' => $area->id]);
}
sleep(10);
}
}
示例3: index
function index()
{
return view('export')->with(['regions' => Region::where('id', '<>', '---')->get()]);
}
示例4:
<?php
include "vendor/autoload.php";
include "config/database.php";
use App\Models\Region;
foreach (Region::all() as $region) {
$parent = Region::where('ts_id', '=', $region->parent_id)->first();
$region->update(array('parent_id' => $parent->id));
}
示例5: edit_kprk
public function edit_kprk($id, $id_kprk)
{
$region = Region::where('regions.id', $id)->first();
$regionKPRK = RegionKPRK::find($id_kprk);
return view('regions.edit_kprk', compact('regionKPRK', 'region'));
}
示例6: parseTenders
protected function parseTenders(Client $client, Crawler $crawler)
{
$repeatSensor = 0;
$contractsNum = 0;
$crawler->filter('div.registerBox')->each(function (Crawler $node, $i) use($client, &$repeatSensor, &$contractsNum) {
$systemId = str_replace('№ ', '', trim($node->filter('td.descriptTenderTd > dl > dt > a')->text()));
$organizationNode = $node->filter('dd.nameOrganization > a');
$organizationName = trim($organizationNode->text());
$organizationUrl = trim($organizationNode->attr('href'));
//Log::info('Node data', [$node->html()]);
$contractName = trim($node->filter('td.descriptTenderTd > dl > dd')->eq(1)->text());
$contractUrl = $node->filter('td.descriptTenderTd > dl > dt > a')->attr('href');
$contractType = trim($node->filter('td.tenderTd > dl > dt')->eq(0)->text());
$contractStatus = '';
/*Log::info('Обработка нового контракта', [
'org_name' => $organizationName,
'org_url' => $organizationUrl,
'name' => $contractName,
'url' => $contractUrl
]);*/
$contract = Contract::where('system_id', $systemId)->first();
if (!$contract) {
$repeatSensor = 0;
// Search organization in database
$organization = Organization::where('url', $organizationUrl)->first();
if (!$organization) {
//Log::info('Организация не найдена, добавляем в базу.');
$organization = new Organization();
$organization->name = $organizationName;
$organization->url = $organizationUrl;
$this->info($organizationUrl);
$organizationResponse = $client->get($organizationUrl);
$organizationCrawler = new Crawler((string) $organizationResponse->getBody());
//Log::info('Информация по организации загружена.');
// Federal Law 223
if (preg_match("/223\\/ppa/", $organizationUrl)) {
$organizationCrawler->filter('div.noticeTabBoxWrapper > table tr')->each(function (Crawler $row, $j) use(&$organization) {
if ($row->children('td')->count() > 1) {
$nameColumn = trim($row->children('td')->eq(0)->text());
$valueColumn = trim($row->children('td')->eq(1)->text());
if ($valueColumn) {
switch ($nameColumn) {
case 'Уровень организации':
$organization->level = $valueColumn;
break;
case 'ИНН':
$organization->inn = $valueColumn;
break;
case 'КПП':
$organization->kpp = $valueColumn;
break;
case 'ОГРН':
$organization->ogrn = $valueColumn;
break;
case 'ОКАТО':
$organization->okato = $valueColumn;
break;
case 'Адрес (место нахождения)':
$addresses = array_map(function ($value) {
return trim($value);
}, explode(',', $valueColumn));
$address = collect($addresses);
$address->forget('Российская Федерация');
$organization->postal_code = $address[0];
$organization->country_id = 1;
$country = Country::find(1);
if (isset($address[3])) {
$region = Region::where('name', $address[2])->where('country_id', $country->id)->first();
if (!$region) {
$region = Region::create(['country_id' => $country->id, 'name' => $address[2]]);
}
$town = Town::where('name', $address[3])->where('region_id', $region->id)->first();
if (!$town) {
$town = Town::create(['region_id' => $region->id, 'name' => $address[3]]);
}
$organization->region_id = $region->id;
$organization->town_id = $town->id;
}
$organization->address = $valueColumn;
break;
case 'Телефон':
$organization->contact_phone = $valueColumn;
break;
case 'Факс':
$organization->contact_fax = $valueColumn;
break;
case 'Почтовый адрес':
$organization->contact_address = $valueColumn;
break;
case 'Контактное лицо':
$organization->contact_name = $valueColumn;
break;
case 'Адрес электронной почты для системных уведомлений':
$organization->contact_email = $valueColumn;
break;
}
}
}
});
} else {
//.........这里部分代码省略.........
示例7: recherche
/**
* Recherche une entrée de la bd.
*
* @return Response
*/
public function recherche()
{
//TODO: mettre cette logique dans index()
$routeActionName = 'ParticipantsController@index';
$listeRecherches = ParticipantsController::getListeRecherches();
$listeFiltres = ParticipantsController::getListeFiltres();
$infosTri = ParticipantsController::getInfosTri();
$input = Input::all();
$valeurFiltre = $input['listeFiltres'];
$valeurRecherche = $input['entreeRecherche'];
if ($valeurRecherche != '') {
if ($valeurFiltre == 0) {
$participants = Participant::where('nom', 'like', $valeurRecherche . '%')->get();
} elseif ($valeurFiltre == 1) {
$participants = Participant::where('prenom', 'like', $valeurRecherche . '%')->get();
} elseif ($valeurFiltre == 2) {
if (is_numeric($valeurRecherche)) {
$participants = Participant::where('numero', $valeurRecherche)->get();
} else {
$participants = new \Illuminate\Database\Eloquent\Collection();
}
} elseif ($valeurFiltre == 3) {
$region = Region::where('nom_court', '=', $valeurRecherche)->first();
if ($region) {
$participants = $region->participants()->get();
} else {
$participants = new \Illuminate\Database\Eloquent\Collection();
}
} else {
$participants = Participant::all();
}
} else {
$participants = Participant::all();
}
$participants = ParticipantsController::trierColonnes($participants);
return View::make('participants.index', compact('participants', 'routeActionName', 'infosTri', 'listeFiltres', 'listeRecherches', 'valeurFiltre', 'valeurRecherche'));
}