本文整理汇总了PHP中app\models\Region::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Region::find方法的具体用法?PHP Region::find怎么用?PHP Region::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Region
的用法示例。
在下文中一共展示了Region::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionView
/**
* Displays a single Profile model.
* @param integer $id
* @return mixed
*/
public function actionView()
{
$model = $this->findModel(Yii::$app->user->id);
$modelRegion = Region::find()->where(['id' => $model->region_id])->one();
$model->region = $modelRegion->name;
// echo '<pre>';
// print_r($model->region);
// echo '</pre>';
// exit;
return $this->render('view', ['model' => $model]);
}
示例2: actionFetchData
public function actionFetchData()
{
$categorys = \yii\helpers\ArrayHelper::toArray(\app\models\CategoryGoogle::find()->all());
$location = \yii\helpers\ArrayHelper::toArray(\app\models\Region::find()->all());
$place = \yii\helpers\ArrayHelper::toArray(\app\models\Place::find()->all());
$placeCategory = \yii\helpers\ArrayHelper::toArray(\app\models\PlaceCategory::find()->all());
$db = ['location' => $location, 'category' => $categorys, 'place' => $place, 'place_category' => $placeCategory];
// echo '<pre>';
// print_r($db);
// print_r($db);
echo json_encode($db);
// echo '</pre>';
}
示例3: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Region::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]);
return $dataProvider;
}
示例4: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Region::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, 'lat' => $this->lat, 'lng' => $this->lng, 'zoom' => $this->zoom, 'radius' => $this->radius, 'provincia_id' => $this->provincia_id]);
$query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'codigo_postal', $this->codigo_postal]);
return $dataProvider;
}
示例5: actionAjaxListChild
/**
* List Region Children for select
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param string $id
* @return mixed
*/
public function actionAjaxListChild($id)
{
//'visible' => Yii::$app->user->can('deleteYourAuth'),
$countChild = Region::find()->where(['parent_id' => $id])->count();
$children = Region::find()->where(['parent_id' => $id])->all();
if ($countChild > 0) {
echo "<option>" . Yii::t('app', 'Please Select') . "</option>";
foreach ($children as $child) {
echo "<option value='" . $child->id . "'>" . $child->name . "</option>";
}
} else {
echo "<option>" . Yii::t('app', 'No Option') . "</option>";
}
}
示例6: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Region::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, 'rec_status_id' => $this->rec_status_id, 'user_id' => $this->user_id, 'dc' => $this->dc]);
$query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'note', $this->note]);
return $dataProvider;
}
示例7: getMenuItems
public static function getMenuItems()
{
$items = [];
$regions = ArrayHelper::map(Region::find()->all(), 'id', 'nameBoth');
$controller = Yii::$app->controller;
foreach ($regions as $key => $value) {
$arrayParams = ['MainSearch' => ['region' => $key]];
$params = array_merge(["site/index"], $arrayParams);
$url = Yii::$app->urlManager->createUrl($params);
$items[] = ['label' => $value, 'url' => $url];
}
$arrayParams = ['MainSearch' => ['region' => -1]];
$params = array_merge(["site/index"], $arrayParams);
$url = Yii::$app->urlManager->createUrl($params);
$items[] = ['label' => 'Պատ. (Random)', 'url' => $url];
if (\Yii::$app->user->can('site.list')) {
$items[] = ['label' => 'Գր. (Library)', 'url' => '/site/list'];
}
if (\Yii::$app->user->can('site.users')) {
$items[] = ['label' => 'Օգտ. (Users)', 'url' => '/site/users'];
}
return $items;
}
示例8:
$form = ActiveForm::begin();
?>
<?php
echo $form->field($model, 'province_code')->textInput(['maxlength' => 32]);
?>
<?php
echo $form->field($model, 'province_description')->textInput(['maxlength' => 32]);
?>
<?php
echo $form->field($model, 'provincecol')->textInput(['maxlength' => 45]);
?>
<?php
echo $form->field($model, 'region_id')->dropdownList(ArrayHelper::map(Region::find()->all(), 'id', 'region_code'), ['prompt' => 'Choose a region']);
?>
<div class="form-group">
<?php
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
</div>
<?php
ActiveForm::end();
?>
</div>
示例9:
<h1><?php
echo Html::encode($this->title);
?>
</h1>
<?php
// echo $this->render('_search', ['model' => $searchModel]);
?>
<p>
<?php
echo Html::a('Create Mon1str', ['create'], ['class' => 'btn btn-success']);
?>
</p>
<?php
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'kartik\\grid\\SerialColumn'], ['attribute' => 'region', 'value' => 'monitoring1.user.profile.region.number', 'filter' => Html::activeDropDownList($searchModel, 'region', ArrayHelper::map(\app\models\Region::find()->asArray()->all(), 'id', 'number'), ['class' => 'form-control', 'prompt' => 'Оберіть код регіону'])], ['attribute' => 'date', 'value' => 'date', 'format' => 'raw', 'width' => '350px', 'filter' => DatePicker::widget(['model' => $searchModel, 'name' => 'date', 'attribute' => 'date', 'options' => ['placeholder' => 'Оберіть місяць ...'], 'pluginOptions' => ['format' => 'yyyy-mm-dd', 'viewMode' => 'months', 'minViewMode' => 'months']])], ['class' => 'yii\\grid\\ActionColumn']]]);
?>
<?php
$m = Yii::$app->request->get();
$excel = ['excel'];
$arrayExcel = ArrayHelper::merge($excel, $m);
?>
<p>
<?php
echo Html::a('Емпортувати в xls', $arrayExcel, ['class' => 'btn btn-success']);
?>
</p>
</div>
示例10: function
</h1>
<?php
// echo $this->render('_search', ['model' => $searchModel]);
?>
<p>
<?php
echo Html::a('<i class="glyphicon glyphicon-plus"></i> Створити моніторинг', ['create'], ['class' => 'btn btn-success']);
?>
</p>
<?php
?>
<?php
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'pjax' => false, 'formatter' => ['class' => 'yii\\i18n\\Formatter', 'nullDisplay' => ''], 'columns' => [['class' => 'kartik\\grid\\SerialColumn'], ['attribute' => 'region', 'value' => 'user.profile.region.number', 'filter' => Html::activeDropDownList($searchModel, 'region', ArrayHelper::map(\app\models\Region::find()->asArray()->all(), 'id', 'number'), ['class' => 'form-control', 'prompt' => 'Оберіть код регіону'])], ['attribute' => 'status', 'format' => 'raw', 'contentOptions' => ['style' => 'text-align:center;'], 'value' => function ($model) {
if ($model->status == 0) {
return '<span class="glyphicon glyphicon-remove" style="color:red;"></span>';
} else {
return '<span class="glyphicon glyphicon-ok" style="color:green"></span>';
}
}, 'filter' => Html::activeDropDownList($searchModel, 'status', [0 => 'не збережено', 1 => 'збережено'], ['class' => 'form-control', 'prompt' => 'Статус'])], ['attribute' => 'date', 'value' => 'date', 'format' => 'raw', 'width' => '350px', 'filter' => DatePicker::widget(['model' => $searchModel, 'name' => 'date', 'attribute' => 'date', 'options' => ['placeholder' => 'Оберіть місяць ...'], 'pluginOptions' => ['format' => 'yyyy-mm-dd', 'viewMode' => 'months', 'minViewMode' => 'months']])], ['class' => 'yii\\grid\\ActionColumn', 'buttons' => ['print' => function ($url, $model, $key) {
return Html::a('<span class="glyphicon glyphicon-print"></span>', $url, ['title' => 'Друк']);
}, 'update' => function ($url, $model, $key) {
if (Yii::$app->user->can('admin') || $model->status == 0) {
return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, ['title' => 'Редагувати']);
}
}, 'delete' => function ($url, $model, $key) {
if (Yii::$app->user->can('admin') || $model->status == 0) {
return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, ['title' => 'Видалити', 'data-confirm' => 'Ви впевнені, що хочете видалити цей запис?', 'data-method' => 'post']);
}
示例11:
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use app\models\Region;
$regions = Region::find()->all();
$lregions = ArrayHelper::toArray($regions, ['app\\models\\Region' => ['id', 'title']]);
$listOfRegions = ArrayHelper::map($lregions, 'id', 'title');
/* @var $this yii\web\View */
/* @var $model app\models\City */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="city-form">
<?php
$form = ActiveForm::begin();
?>
<?php
echo $form->field($model, 'title')->textInput(['maxlength' => true]);
?>
<?php
echo $form->field($model, 'region_id')->dropDownList($listOfRegions);
?>
<div class="form-group">
<?php
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
示例12:
// ->all(),
// 'autoFocus' => true,
// 'minLength' => '1',
// 'delay' => '100',
//// 'change' => new \yii\web\JsExpression("function( event, ui ) {
//// if(!ui.item) $('#address-region_id').val('');
//// }"),
//// 'select' => new \yii\web\JsExpression("function( event, ui ) {
//// $('#address-region_id').val(ui.item.id);
//// }"),
// ],
//]);
?>
<?php
echo $form->field($model, 'region_name')->widget(\dosamigos\selectize\SelectizeDropDownList::className(), ['items' => \yii\helpers\ArrayHelper::map(\app\models\Region::find()->select(['name'])->active()->orderBy('name asc')->asArray()->all(), 'name', 'name'), 'options' => ['multiple' => false, 'class' => 'form-control', 'prompt' => ''], 'clientOptions' => ['allowEmptyOption' => true, 'selectOnTab' => true, 'openOnFocus' => false, 'persist' => false, 'maxItems' => 1, 'create' => true, 'valueField' => 'name', 'labelField' => 'name', 'searchField' => ['name']]])->hint('');
?>
<?php
// echo $form->field($model, 'city_id')->textInput()
?>
<?php
echo $form->field($model, 'city_name')->widget(\dosamigos\selectize\SelectizeDropDownList::className(), ['items' => \yii\helpers\ArrayHelper::map(\app\models\City::find()->select(['name'])->active()->orderBy('name asc')->asArray()->all(), 'name', 'name'), 'options' => ['multiple' => false, 'class' => 'form-control', 'prompt' => ''], 'clientOptions' => ['selectOnTab' => true, 'openOnFocus' => false, 'persist' => false, 'maxItems' => 1, 'create' => true, 'valueField' => 'name', 'labelField' => 'name', 'searchField' => ['name']]])->hint('');
?>
<?php
/*echo $form->field($model, 'city_name')->widget(\kartik\select2\Select2::classname(), [
'data' => \app\models\City::find()
->select(['name'])
->active()
示例13: Region
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use app\models\Region;
use app\models\City;
/* @var $this yii\web\View */
/* @var $model app\models\School */
/* @var $form yii\widgets\ActiveForm */
?>
<?php
$region = new Region();
$regions = ArrayHelper::toArray(Region::find()->all(), ['app\\models\\Region' => ['id', 'title']]);
$listOfRegions = ArrayHelper::map($regions, 'id', 'title');
$cities = ArrayHelper::toArray(City::find()->all(), ['app\\models\\City' => ['id', 'title']]);
$listOfCities = ArrayHelper::map($cities, 'id', 'title');
?>
<div class="school-form">
<?php
$form = ActiveForm::begin();
?>
<?php
echo $form->field($model, 'name')->textInput(['maxlength' => true]);
?>
<?php
示例14:
<div class="address-index">
<h1><?php
//echo Html::encode($this->title)
?>
</h1>
<?php
// echo $this->render('_search', ['model' => $searchModel]);
?>
<p class='pull-left'>
<?php
echo \yii\helpers\Html::a('<span class="glyphicon glyphicon-plus"></span> ' . Yii::t('app', 'Create new'), ['create'], ['class' => 'btn btn-success']);
?>
</p>
<div class="clearfix"></div>
<?php
\yii\widgets\Pjax::begin();
?>
<?php
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'region_id' => ['attribute' => 'region_id', 'value' => 'region.name', 'filter' => ArrayHelper::map(\app\models\Region::find()->active()->all(), 'id', 'name')], 'city_id' => ['attribute' => 'city_id', 'value' => 'city.name', 'filter' => ArrayHelper::map(\app\models\City::find()->active()->all(), 'id', 'name')], 'street', 'house', 'room', ['class' => 'yii\\grid\\ActionColumn', 'contentOptions' => ['style' => 'white-space: nowrap;']]], 'tableOptions' => ['class' => 'table table-striped table-hover']]);
?>
<?php
\yii\widgets\Pjax::end();
?>
</div>
示例15: getAccessableOfficesWhereUserIs
public function getAccessableOfficesWhereUserIs($role)
{
switch ($role) {
case self::MANAGER:
return $this->offices;
break;
case self::COMDIR:
/* Коммерческий директор имеет доступ к офисам своего региона */
$offices = [];
$regions = Region::find(['user_id' => 'id'])->innerJoin('questionlist_users_to_regions utr', 'utr.region_id=' . Region::tableName() . '.id', ['utr.user_id' => $this->id])->with('offices')->all();
if (!$regions) {
return;
}
foreach ($regions as $region) {
$offices = array_merge($offices, $region->offices);
}
return $offices;
break;
case self::ADMIN:
/* Админ имеет доступ к всем офисам */
if (!$this->isAdmin) {
return;
}
return Office::find()->all();
break;
}
}