本文整理汇总了PHP中app\models\Location::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Location::find方法的具体用法?PHP Location::find怎么用?PHP Location::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Location
的用法示例。
在下文中一共展示了Location::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createEmptyStock
public static function createEmptyStock($item)
{
$stock = $item->newStockOnLocation(Location::find(1));
$stock->quantity = 0;
$stock->reason = 'stock created';
$stock->save();
return $stock;
}
示例2: search
/**
* Поиск
* @param $params
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Location::find();
$query->joinWith(['country', 'city', 'region', 'users']);
$dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['attributes' => ['users.name', 'users.email', 'country', 'region', 'city']], 'pagination' => ['pagesize' => 5]]);
if (!($this->load($params) && $this->validate())) {
return $dataProvider;
}
$query->andWhere('country LIKE "%' . $this->country . '%"');
$query->andWhere('city LIKE "%' . $this->city . '%"');
$query->andWhere('region LIKE "%' . $this->region . '%"');
return $dataProvider;
}
示例3: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Location::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'created' => $this->created, 'updated' => $this->updated, 'is_active' => $this->is_active]);
$query->andFilterWhere(['like', 'nickname', $this->nickname])->andFilterWhere(['like', 'fullname', $this->fullname]);
return $dataProvider;
}
示例4: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Location::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'annual_budget' => $this->annual_budget]);
$query->andFilterWhere(['like', 'location_name', $this->location_name])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'country', $this->country]);
return $dataProvider;
}
示例5: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Location::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'status' => $this->status]);
$query->andFilterWhere(['like', 'title', $this->title]);
return $dataProvider;
}
示例6: scopeLocation
/**
* Filters inventory results by specified location.
*
* @param mixed $query
* @param int|string $locationId
*
* @return mixed
*/
public function scopeLocation($query, $locationId = null)
{
if (!is_null($locationId)) {
// Get descendants and self inventory category nodes
$locations = Location::find($locationId)->getDescendantsAndSelf();
// Perform a sub-query on main query
$query->where(function ($query) use($locations) {
// For each category, apply a orWhere query to the sub-query
foreach ($locations as $location) {
$query->orWhere('location_id', $location->id);
}
});
}
return $query;
}
示例7: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Location::find();
$query->joinWith(['room']);
$dataProvider = new ActiveDataProvider(['query' => $query]);
$dataProvider->sort->attributes['room'] = ['asc' => ['room.name' => SORT_ASC], 'desc' => ['room.name' => SORT_DESC]];
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'active' => $this->active]);
$query->andFilterWhere(['like', 'location', $this->location])->andFilterWhere(['like', 'room.name', $this->room]);
return $dataProvider;
}
示例8: beforeAction
public function beforeAction($action)
{
if (!parent::beforeAction($action)) {
return false;
}
$locationModels = Location::find()->where(['status' => Location::STATUS_ACTIVE])->all();
$locations = [];
foreach ($locationModels as $locationModel) {
$locations[$locationModel->id] = $locationModel->title;
}
$categoryModels = Category::find()->where(['status' => Location::STATUS_ACTIVE])->all();
$categories = [];
foreach ($categoryModels as $categoryModel) {
$categories[$categoryModel->id] = $categoryModel->title;
}
$searchBar = ['locations' => $locations, 'categories' => $categories];
$this->view->params['search_bar'] = $searchBar;
return true;
}
示例9: save
/**
*
*/
public function save(Request $request)
{
$out = ['data' => $request->input()];
if (!$request->has('id')) {
$location = new \App\Models\Location();
$geojsonLocation = new \App\Models\GeojsonLocation();
} else {
$location = \App\Models\Location::find($request->input('id'));
$geojsonLocation = \App\Models\GeojsonLocation::find($request->input('id'));
}
$location->name = $request->input('name');
$location->description = $request->input('description');
// get the center
$geometry = $request->input('geometryWkt');
$polygon = \geoPHP::load($geometry);
$polygon->setSRID(4326);
$srid = $polygon->SRID();
$geos = \geoPHP::geosInstalled();
$valid = $polygon->checkValidity();
$centroid = $polygon->getCentroid();
$area = $polygon->getArea();
$location->center = \DB::raw("ST_SetSRID(ST_PointFromText('POINT(" . $centroid->getX() . ' ' . $centroid->getY() . ")'), 4326)");
$location->bounds = \DB::raw("ST_SetSRID(ST_PolygonFromText('" . $geometry . "'), 4326)");
$location->area = $area;
$location->save();
// save it in the mongo model too...
$geojsonLocation->name = $request->input('name');
$geojsonLocation->description = $request->input('description');
$geojsonLocation->area = $area;
// save the center as GeoJSON
$centroidWkt = \geoPHP::load('POINT(' . $centroid->getX() . ' ' . $centroid->getY() . ')', 'wkt');
$geojsonLocation->center = json_decode($centroidWkt->out('json'));
// save the geometry as geoJSON
$geojsonLocation->bounds = json_decode($polygon->out('json'));
$geojsonLocation->save();
$out['data']['location'] = $location;
$out['data']['geojsonLocation'] = $geojsonLocation;
return Response::json($out);
}
示例10: function
Route::get('{userId}/assets', ['as' => 'api.users.assetlist', 'uses' => 'UsersController@getAssetList']);
Route::post('{userId}/upload', ['as' => 'upload/user', 'uses' => 'UsersController@postUpload']);
});
/*---Groups API---*/
Route::group(['prefix' => 'groups'], function () {
Route::get('list', ['as' => 'api.groups.list', 'uses' => 'GroupsController@getDatatable']);
});
/*---Licenses API---*/
Route::group(['prefix' => 'licenses'], function () {
Route::get('list', ['as' => 'api.licenses.list', 'uses' => 'LicensesController@getDatatable']);
});
/*---Locations API---*/
Route::group(['prefix' => 'locations'], function () {
Route::resource('/', 'LocationsController');
Route::get('{locationID}/check', function ($locationID) {
$location = Location::find($locationID);
return $location;
});
});
/*---Improvements API---*/
Route::group(['prefix' => 'asset_maintenances'], function () {
Route::get('list', ['as' => 'api.asset_maintenances.list', 'uses' => 'AssetMaintenancesController@getDatatable']);
});
/*---Models API---*/
Route::group(['prefix' => 'models'], function () {
Route::resource('/', 'AssetModelsController');
Route::get('list/{status?}', ['as' => 'api.models.list', 'uses' => 'AssetModelsController@getDatatable']);
Route::get('{modelID}/view', ['as' => 'api.models.view', 'uses' => 'AssetModelsController@getDataView']);
});
/*--- Categories API---*/
Route::group(['prefix' => 'categories'], function () {
示例11: implode
use yii\widgets\ActiveForm;
AppAsset::register($this);
/* select info company */
$info = Infocompany::find()->one();
/* select slide */
$slides = Slide::find()->where(['position' => '1'])->all();
/* select article*/
$article = Article::find()->where(['hot' => '1'])->all();
/* select article services */
$articleService = Article::find()->where(['type' => "100"])->all();
$services = [];
for ($i = 0; $i < count($articleService); $i++) {
$services[] = ['label' => $articleService[$i]->title, 'url' => ['article/' . implode('-', explode(' ', $articleService[$i]->title))]];
}
$this->title = $info->name;
$hotelInfo = \app\models\Location::find()->all();
$hotelMenu = [];
for ($i = 0; $i < count($hotelInfo); $i++) {
$item = [];
$item['label'] = 'Hotels in ' . $hotelInfo[$i]->name;
$hotelName = implode('-', explode(" ", $hotelInfo[$i]->name));
$item['url'] = ['hotel/' . $hotelName];
$hotelMenu[] = $item;
}
?>
<?php
$this->beginPage();
?>
<!DOCTYPE html>
<html lang="<?php
示例12: ActiveDataProvider
<div class="row">
<div class="col-lg-4">
<h2>Топ стран</h2>
<?php
$dataProvider = new ActiveDataProvider(['query' => Location::find()->joinWith('country')->select(['country_id', 'country', 'COUNT(*) AS cnt'])->where('country != ""')->groupBy('country')->orderBy('cnt DESC')->limit(5)]);
echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'country.country', 'cnt'], 'layout' => "{items}"]);
?>
</div>
<div class="col-lg-4">
<h2>Топ регинов</h2>
<?php
$dataProvider = new ActiveDataProvider(['query' => Location::find()->joinWith('region')->select(['region_id', 'region', 'COUNT(*) AS cnt'])->where('region != ""')->groupBy('region')->orderBy('cnt DESC')->limit(5)]);
echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'region.region', 'cnt'], 'layout' => "{items}"]);
?>
</div>
<div class="col-lg-4">
<h2>Пустые города</h2>
<?php
$dataProvider = new ArrayDataProvider(['allModels' => Location::find()->joinWith('city', false, 'RIGHT JOIN')->select(['city_id', 'city.city'])->where('location.id IS NULL')->asArray()->all()]);
echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['label' => 'Город', 'value' => 'city']], 'layout' => "{items}"]);
?>
</div>
</div>
</div>
</div>
示例13: function
</li>
<li>
<p>Status</p>
<select name="Status" id="status" class="form-control">
<option value=" ">All</option>
<option value="1">Active</option>
<option value="0">Deactive</option>
</select>
</li>
</ul>
<?php
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['class' => 'yii\\grid\\CheckboxColumn', 'headerOptions' => ['class' => 'sr-only']], ['attribute' => 'smallimg', 'format' => 'image', 'value' => function ($model) {
return '@web/images/' . $model->smallimg;
}], 'name', 'star', ['attribute' => 'id_location', 'value' => 'location.name', 'filter' => \yii\helpers\ArrayHelper::map(\app\models\Location::find()->all(), 'name', 'name'), 'options' => ['width' => '200px']], 'address', 'editdate', ['attribute' => 'status', 'headerOptions' => ['class' => 'sr-only'], 'filterOptions' => ['class' => 'sr-only'], 'contentOptions' => ['class' => 'sr-only']], ['class' => 'yii\\grid\\ActionColumn', 'urlCreator' => function ($action, $model, $key, $index) {
if ($action === 'view') {
$url = '/hotel/show-detail/' . $model->id;
return $url;
} elseif ($action === 'update') {
$url = '/hotel/update/' . $model->id;
return $url;
} else {
$url = '/hotel/delete/' . $model->id;
return $url;
}
}]]]);
?>
</div>
示例14: actionIndex
/**
* Lists all Location models (limit 20)
* @return mixed
*/
public function actionIndex()
{
$dataProvider = new ActiveDataProvider(['query' => Location::find(), 'totalCount' => 20, 'pagination' => ['defaultPageSize' => 20]]);
return $this->render('index', ['dataProvider' => $dataProvider]);
}
示例15: actionIndex
/**
* Lists all Location models.
* @return mixed
*/
public function actionIndex()
{
$dataProvider = new ActiveDataProvider(['query' => Location::find()]);
return $this->render('index', ['dataProvider' => $dataProvider]);
}