コード例 #1
0
 public function loginProvider()
 {
     /** @var Provider $model */
     $model = Provider::find()->where(['email' => $this->username])->one();
     if (!is_null($model) && $model->password == $this->password) {
         return $model;
     } else {
         $this->addError('password', Yii::t('app', 'Incorrect User or Password'));
         return null;
     }
 }
コード例 #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Provider::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]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
コード例 #3
0
ファイル: BrandController.php プロジェクト: dao94/game
 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function index($slug)
 {
     $explodeSlug = explode('-', $slug);
     $brandId = explode('.', end($explodeSlug))[0];
     if (!$brandId) {
         return false;
     }
     $obj = new Product();
     $AllparentID = Provider::where('parent_key', $brandId)->get()->toArray();
     $idPr = [];
     if ($AllparentID) {
         foreach ($AllparentID as $val) {
             array_push($idPr, $val['id']);
         }
         $res = Product::whereIn('provider_id', $idPr)->orderBy('id', 'desc');
     } else {
         $res = Product::where('provider_id', $brandId)->orderBy('id', 'desc');
     }
     $res = $this->paging($res, $this->req, false);
     $brandName = Provider::find($brandId);
     $data = ['title' => 'Nhãn hiệu', 'brand_name' => $brandName->name, 'product' => $res, 'total' => $this->total, 'total_page' => $this->total_page];
     return View::make('user/brand', $data);
 }
コード例 #4
0
 /**
  * Lists all Provider models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Provider::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
コード例 #5
0
ファイル: _search.php プロジェクト: rcjusto/simplestore
<?php

use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model app\models\ProductSearch */
/* @var $form yii\widgets\ActiveForm */
$categories = ArrayHelper::map(\app\models\Category::find()->orderBy(['url_code' => SORT_ASC])->all(), 'id', 'name');
$providers = ArrayHelper::map(\app\models\Provider::find()->orderBy(['name' => SORT_ASC])->all(), 'id', 'name');
$hideFilter = empty($model->code) && empty($model->name) && empty($model->active) && empty($model->category_id) && empty($model->provider_id);
?>

<div class="product-search" style="background-color: #f8f8f8;padding: 1px 20px;margin-bottom: 10px;position: relative;">

    <a href="#" style="position: absolute;right: 15px;top:5px;" onclick="$('.filters').toggle();return false;">Show/Hide Filters</a>
    <div class="filters" style="<?php 
echo $hideFilter ? 'display: none;' : '';
?>
">
    <h3>Filter by</h3>

    <?php 
$form = ActiveForm::begin(['action' => ['index'], 'method' => 'get']);
?>

    <div class="row">
        <div class="col-sm-2">
            <?php 
echo $form->field($model, 'code');
?>
コード例 #6
0
 /**
  * Reads a Provider
  *
  * @param  string  $provider_id
  * @return \App\Models\Provider
  */
 public function get($provider_id)
 {
     return \App\Models\Provider::find($provider_id);
 }
コード例 #7
0
ファイル: ProviderController.php プロジェクト: dao94/game
 public function postDelbyid(Request $request)
 {
     $id = $request->input('id');
     if (!$id) {
         $this->error = false;
         $this->error_message = 'Error , please submit again !';
         goto next;
     }
     try {
         $obj = Provider::find($id);
         $obj->delete();
         $this->message = 'Xóa nhà cung cấp thành công !';
     } catch (Exception $e) {
         $this->error = false;
         $this->error_message = $e->getMessage();
     }
     next:
     return $this->ResponseData();
 }