public function actionCreate()
 {
     $category = new Category();
     if ($category->load(Yii::$app->request->post()) && $category->validate()) {
         $category->save();
         Yii::$app->getSession()->setFlash('success', 'You added new category successfully');
         return $this->redirect(Yii::$app->urlManager->createUrl('category'));
     }
     return $this->render('create', ['category' => $category]);
 }
 public static function test()
 {
     $category = Category::find()->one()->getNewses()->createCommand()->sql;
     //$news = $category->newses;
     echo '<pre>';
     var_dump($category);
 }
Example #3
0
 /**
  * Creates a new Post model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Post();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model, 'category' => Category::find()->all(), 'authors' => User::find()->all()]);
     }
 }
Example #4
0
 public static function getAllMenu()
 {
     $categoryModel = new Category();
     $categories = $categoryModel->getCategories(0);
     $data['category_id'] = 0;
     $data['categories'] = array();
     foreach ($categories as $category) {
         $children_data = array();
         if ($category['category_id'] != $data['category_id']) {
             $children = $categoryModel->getCategories($category['category_id']);
             foreach ($children as $child) {
                 $children_data[] = array('category_id' => $child['category_id'], 'name' => $child['name'], 'href' => 'product/category/' . 'path=' . $category['category_id'] . '_' . $child['category_id']);
             }
         }
         $data['category_id'] = $category['category_id'];
         $data['categories'][] = array('category_id' => $category['category_id'], 'name' => $category['name'], 'children' => $children_data, 'href' => 'product/category.' . 'path=' . $category['category_id']);
     }
     return $data;
 }
Example #5
0
 public function actionViewbycat($cat)
 {
     $this->layout = "sidemenu";
     $category = Category::find()->where(['category_name' => $cat])->one();
     if (!$category) {
         throw new NotFoundHttpException('The requested page does not exist.');
     } else {
         $product = Product::find()->where(['product_category' => $category->category_id])->all();
         return $this->render('index', ['model' => $product]);
     }
 }
 /**
  * @param integer $id
  * @return mixed
  * @throws NotFoundHttpException if the model cannot be found
  */
 public function run($id)
 {
     $category = Category::findOne(['id' => $id]);
     if (!empty($category)) {
         $param = ['category' => $id];
         $extraOptions = ['filterEnable' => true];
         return $this->controller->renderIndex($param, $extraOptions);
     } else {
         $this->controller->redirect(['/transaction']);
     }
 }
 public function actionView($id)
 {
     $article = Articles::find()->where(['id' => $id])->one();
     $article->view = $article->view + 1;
     $article->save(false);
     $popularArticle = Articles::find()->orderBy('view DESC')->limit(5)->all();
     $discussedArticle = Articles::find()->joinWith('comments', true, 'RIGHT JOIN')->groupBy('comments.article_id')->orderBy('count(comments.article_id) DESC')->limit(5)->all();
     $modelCategory = Category::find()->all();
     $model = $this->findModel($id);
     $comments = Comments::find()->with('user')->where(['article_id' => $id, 'enable' => 1])->all();
     $user = User::find()->where(['id' => $model->author_id])->one();
     return $this->render('view', ['model' => $model, 'modelCategory' => $modelCategory, 'user' => $user, 'comments' => $comments, 'popularArticle' => $popularArticle, 'discussedArticle' => $discussedArticle]);
 }
Example #8
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Category::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;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Category::find();
     // add conditions that should always apply here
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'pid' => $this->pid, 'sort' => $this->sort, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }
Example #10
0
 /**
  * Displays homepage.
  *
  * @return mixed
  */
 public function actionIndex()
 {
     $modelCategory = Category::find()->all();
     $modelArticle = Articles::find()->with('articleImg')->orderBy('id DESC')->all();
     $popularArticle = Articles::find()->orderBy('view DESC')->limit(5)->all();
     $discussedArticle = Articles::find()->joinWith('comments', true, 'RIGHT JOIN')->groupBy('comments.article_id')->orderBy('count(comments.article_id) DESC')->limit(5)->all();
     $arrUser = array();
     $userName = array();
     foreach ($modelArticle as $article) {
         $arrUser[] = $article['author_id'];
     }
     foreach ($arrUser as $i => $user) {
         $userModel = User::find()->where(['id' => $user])->all();
         $userName[] = $userModel[0];
     }
     return $this->render('index', ['modelCategory' => $modelCategory, 'modelArticle' => $modelArticle, 'userName' => $userName, 'popularArticle' => $popularArticle, 'discussedArticle' => $discussedArticle]);
 }
 public function actionTest()
 {
     Category::test();
 }
Example #12
0
        <li><a href="https://plus.google.com/" target="_blank">
          <div class="social-btn z-depth-1"><i class="zmdi zmdi-google-plus"></i></div>
        </a></li>
      </ul>
    </div>
  </div>
</footer>

</div>
<div class="category-sidenav overflow-hidden">
  <div class="row">
    <div class="head-close-block">
      <i class="zmdi zmdi-hc-3x zmdi-close"></i>
    </div>
    <?php 
foreach (Category::find()->orderBy('id')->all() as $category) {
    ?>
    <div class="col l2 m3 s6">
      <a href="/<?php 
    echo $category->slug;
    ?>
/">
        <div class="category-card">
          <img class="responsive-img z-depth-1" src="/uploads/categories/<?php 
    echo $category->img;
    ?>
">
          <span class="category-card-icon"><i class="zmdi zmdi-hc-3x <?php 
    echo $category->icon;
    ?>
"></i></span>
 /**
  * @param \frontend\models\Transaction $model
  *
  * @return string
  */
 public static function getCategoryForBlockString(Transaction $model)
 {
     $result = [];
     $transaction2Categories = $model->transaction2Category;
     if (!empty($transaction2Categories)) {
         /** @var Transaction2Category $transaction2Category */
         foreach ($transaction2Categories as $transaction2Category) {
             /** @var Category $category */
             $category = Category::find()->andWhere(['id' => $transaction2Category->category_id])->one();
             if (isset($category)) {
                 $result[] = Html::a($category->title, Yii::$app->urlManager->createUrl(['transaction/category', 'id' => $category->id]), ['class' => 'tag tag-blue', 'data-pjax' => '0']);
             }
         }
     }
     return implode(' ', $result);
 }
Example #14
0
 /**
  * Finds the Category model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return Category the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Category::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #15
0
</a> - in <b><?php 
        echo $order->city;
        ?>
</b> Added: <i><?php 
        echo $formatedDate;
        ?>
</i>
            </li>
        <?php 
    }
    ?>
    </ul>
    <ul class="list-group">

        <h1 class="page-header">Posts: <?php 
    echo Category::findOne($_GET['category'])->name;
    ?>
</h1>
<?php 
    foreach ($postOrders as $post) {
        ?>
            <?php 
        $author = Author::getAuthor($post->author_id);
        ?>
            <li class="list-group-item">
                Title: <a href="<?php 
        echo Yii::$app->urlManager->createUrl(['posts/details', 'id' => $post->id]);
        ?>
"><?php 
        echo $post->title;
        ?>
Example #16
0
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="job-edit">
<h1 class="page-header">Edit Job</h1>
    <?php 
$form = ActiveForm::begin();
/*
 * hide errors in production
 */
?>
    <?php 
echo $form->errorSummary($job);
?>

    <?php 
echo $form->field($job, 'category_id')->dropDownList(Category::find()->select(['name', 'id'])->indexBy('id')->column(), ['prompt' => 'Select Category']);
?>
    <?php 
echo $form->field($job, 'title');
?>
    <?php 
echo $form->field($job, 'description')->textarea(['rows' => 4]);
?>
    <?php 
echo $form->field($job, 'type')->dropDownList(['full_time' => 'Full-Time', 'part_time' => 'Part-Time', 'as_needed' => 'As Needed'], ['prompt' => 'Select job-type']);
?>
    <?php 
echo $form->field($job, 'reqierement');
?>
    <?php 
echo $form->field($job, 'salary')->dropDownList(['$20-40k' => '$20 - 40k', '$40-60k' => '$40 - 60k', '$60-80k' => '$60 - 80k', '$80-100k' => '$80 - 100k', 'over' => 'Over $100k', 'blank' => 'No chosen'], ['prompt' => 'Choose salary range']);
Example #17
0
echo Html::encode($this->title);
?>
</title>
    <?php 
$this->head();
?>
</head>
<body>
    <?php 
$this->beginBody();
?>
    <div class="wrap">
        <?php 
NavBar::begin(['brandLabel' => 'Anon Shop.com', 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-inverse navbar-fixed-top']]);
$dropDownItems = [];
$items = Category::find()->all();
foreach ($items as $data) {
    $dropDownItems[] = ['label' => $data->category_name, 'labelTemplate' => '{<h1>hahaha</h1>}', 'url' => ['customer/viewbycat', 'cat' => $data->category_name]];
}
$menuItems = [['label' => 'Home', 'url' => ['/customer/index']], ['label' => 'Category', 'items' => $dropDownItems]];
if (Yii::$app->user->isGuest) {
    $menuItems[] = ['label' => 'Signup', 'url' => ['/site/signup']];
    $menuItems[] = ['label' => 'Login', 'url' => ['/site/login']];
} else {
    $menuItems[] = ['label' => 'Profile', 'url' => ['/customer/profile']];
    $menuItems[] = ['label' => 'Cart', 'url' => ['/customer/cart']];
    $menuItems[] = ['label' => 'Logout (' . Yii::$app->user->identity->username . ')', 'url' => ['/site/logout'], 'linkOptions' => ['data-method' => 'post']];
}
echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-right'], 'items' => $menuItems]);
NavBar::end();
?>
 public function actionIndex($slug)
 {
     $category = Category::find()->where(['slug' => $slug])->one();
     return $this->render('index', ['category' => $category]);
 }
Example #19
0
                                <?php 
echo Html::label('Max Price', '', ['id' => 'min-price']);
?>
                                <?php 
echo Html::input('number', 'maxprice', '', ['id' => 'max-input', 'autocomplete' => 'off', 'class' => 'form-control', 'required' => '', 'type' => 'number', 'step' => '1000', 'min' => '1000', 'max' => '1000000000']);
?>
 
                        </div>

                        <div class="form-group">

                                <?php 
echo Html::label('Category', '', ['id' => 'min-price']);
?>
                                <?php 
echo Html::dropDownList('category', '', ArrayHelper::map(Category::find()->all(), 'category_id', 'category_name'), ['class' => 'form-control']);
?>
 
                        </div>                
                            

                            

                                <?php 
echo Html::submitButton('Search Product', ['class' => 'btn btn-primary']);
?>

                           

                    <?php 
echo Html::endForm();
 function actionUpload()
 {
     $keys = $this->getKeys();
     if (!$keys) {
         return false;
     }
     $key = $keys['file_key'];
     $t = time();
     $img_dir = Yii::$app->params[$keys['params_key']];
     $date = date($img_dir['date_fmt'], $t);
     if (Yii::$app->user->isGuest) {
         $id_user = Yii::$app->session->getHasSessionId();
     } else {
         $id_user = Yii::$app->user->id;
     }
     if (!Yii::$app->user->isGuest) {
         if (empty($_POST['id_item']) && empty(Yii::$app->session[$keys['key_id_item']])) {
             $item = new Product();
             $item->attributes = $_POST['Product'];
             $item->item_state = Product::STATE_ROUGH_COPY & Product::STATE_PUBLISH;
             $item->id_cat = Category::checkCategory($_POST['Product']['category']);
             $item->save(false);
             $id_item = $item->id;
             Yii::$app->session[$keys['key_id_item']] = $id_item;
             if (!empty($_POST['ProductInfo']['full_text'])) {
                 $item_i = new ProductInfo();
                 $item_i->id = $id_item;
                 $item_i->attributes = $_POST['ProductInfo'];
                 $item_i->save(false);
             }
         } else {
             if (!empty(Yii::$app->session[$keys['key_id_item']])) {
                 $id_item = Yii::$app->session[$keys['key_id_item']];
                 //$item = Product::model()->findByPk(Yii::$app->session[$keys['key_id_item']]);
             } else {
                 if (!empty($_POST['id_item'])) {
                     //$item = Product::model()->findByPk($_POST['id_item']);
                     $id_item = $_POST['id_item'];
                 }
             }
         }
         $mainImg = Yii::$app->db->createCommand('SELECT prod_images.id, prod_images.date_create, prod_images.img_url FROM {{%product}} product INNER JOIN {{%prod_images}} prod_images ON product.id_mainImg=prod_images.id WHERE product.id=:id')->bindParam(':id', $id_item)->queryOne();
         $c_images = Yii::$app->db->createCommand('SELECT COUNT(id) FROM {{%prod_images}} WHERE id_prod=:prod')->bindParam(':prod', $id_item)->queryScalar();
     } else {
         $mainImg = Yii::$app->db->createCommand('SELECT id, date_create, img_url FROM {{%prod_temp_images}} images WHERE id_session=:id AND is_main=1')->bindParam(':id', $id_user)->queryOne();
         $c_images = Yii::$app->db->createCommand('SELECT COUNT(id) FROM {{%prod_temp_images}} WHERE id_session=:prod')->bindParam(':prod', $id_user)->queryScalar();
     }
     foreach ($img_dir as $k => &$dir) {
         if ($k == 'date_fmt') {
             continue;
         }
         if (is_array($dir)) {
             foreach ($dir as &$path) {
                 $path = strtr($path, array('{id_user}' => $id_user, '{id_item}' => $id_item));
                 CLib::createFolders($path);
             }
         } else {
             $dir = strtr($dir, array('{id_user}' => $id_user, '{id_item}' => $id_item));
             CLib::createFolders($dir);
         }
     }
     $targetFolder = $img_dir['origin'];
     $bigFolder = $img_dir['big'];
     $tmpFolder = $img_dir['tmp'];
     $previewFolder = $img_dir['preview'];
     if (!count($_FILES[$key])) {
         return false;
     }
     $info = array();
     $size = 1200;
     // px
     $max_files = Yii::$app->params['max_images'];
     $tempFile = $_FILES[$key]['tmp_name'];
     $fileName = md5($id_user . $_FILES[$key]['name'] . $t . rand(0, 1000));
     $type = explode('/', $_FILES[$key]['type']);
     //$fileName.='.'.$type[1];
     $fileName .= '.jpeg';
     $newFile = $tmpFolder . $fileName;
     // перенести во временную папку
     move_uploaded_file($tempFile, $newFile);
     if (!file_exists($newFile)) {
         $vr['err'] = CLib::param('FILE_TO_BIG');
         $vr['no_image'] = true;
         echo json_encode(array('files' => array($vr)));
         return;
     }
     $f_size = filesize($newFile);
     // TODO
     if ($max_files <= $c_images) {
         unlink($newFile);
         $vr['err'] = CLib::param('FILE_IMAGE_LIMIT');
         $vr['err_limit'] = true;
     } else {
         if ($f_size > MAX_SIZE) {
             unlink($newFile);
             $vr['err'] = CLib::param('FILE_TO_BIG');
             $vr['no_image'] = true;
         } else {
             $mime = explode('/', FileHelper::getMimeType($newFile));
             if ($mime[1] != 'jpeg' && $mime[1] != 'jpg') {
                 unlink($newFile);
                 $vr['err'] = CLib::param('FILE_NO_IMAGE');
                 $vr['no_image'] = true;
             } else {
                 $w_norm = $h_norm = $size;
                 copy($newFile, $targetFolder . $fileName);
                 CLib::resizeImgToSmall($w_norm, $h_norm, $targetFolder . $fileName, false, 80, false, true);
                 //
                 $size = 1200;
                 $w_norm = $h_norm = $size;
                 $t_start = microtime(true);
                 unlink($newFile);
                 $newFile = $targetFolder . $fileName;
                 copy($newFile, $bigFolder . $fileName);
                 CLib::resizeImgToSmall($w_norm, $h_norm, $bigFolder . $fileName, false, 80);
                 //
                 $t_end = microtime(true);
                 $vr['time']['diff2'][] = $t_end - $t_start;
                 foreach ($previewFolder as $size => $folder) {
                     $w_norm = $h_norm = (int) $size;
                     if (!file_exists($folder)) {
                         mkdir($folder);
                     }
                     $img = $folder . $fileName;
                     copy($newFile, $img);
                     CLib::resizeImgToSmall($w_norm, $h_norm, $img, $size == 300 || $size == 100, 80);
                 }
                 //unlink($newFile);
                 //$command->bindParam(':filename',$fileName)->execute();
                 //$id = Yii::$app->db->getLastInsertID();
                 if (!Yii::$app->user->isGuest) {
                     $sql = 'INSERT INTO {{%prod_images}} SET id_prod=:prod, img_url=:url, date_create=:date';
                     Yii::$app->db->createCommand($sql)->bindParam(':prod', $id_item)->bindParam(':url', $fileName)->bindParam(':date', $t)->execute();
                 } else {
                     $sql = 'INSERT INTO {{%prod_temp_images}} SET id_session=:id_user, img_url=:url, date_create=:date';
                     Yii::$app->db->createCommand($sql)->bindParam(':id_user', $id_user)->bindParam(':url', $fileName)->bindParam(':date', $t)->execute();
                 }
                 /*
                 $img_model = new ProdImages();
                 $img_model->id_prod = $id_item;
                 $img_model->img_url = $fileName;
                 $img_model->date_create = $t;
                 $img_model->save(false);
                 */
                 $id_img = Yii::$app->db->lastInsertID;
                 if (!Yii::$app->user->isGuest) {
                     if (empty($mainImg['date_create']) || !CLib::checkProdImg(Yii::$app->user->id, $id_item, $mainImg['img_url'])) {
                         $mainImg['id'] = $id_img;
                         Yii::$app->db->createCommand('UPDATE {{%product}} SET id_mainImg=:img WHERE id=:id')->bindParam(':id', $id_item)->bindParam(':img', $id_img)->execute();
                         /*
                         $item->id_mainImg = $img_model->id;
                         $item->save(false);
                         */
                     }
                 } else {
                     if (!isset(Yii::$app->session['prod_images'])) {
                         $arr = array();
                     } else {
                         $arr = Yii::$app->session['prod_images'];
                     }
                     $arr[] = $id_img;
                     Yii::$app->session['prod_images'] = $arr;
                     if (empty($mainImg['date_create']) || !CLib::checkProdImg($id_user, $id_item, $mainImg['img_url'])) {
                         $mainImg['id'] = $id_img;
                         Yii::$app->db->createCommand('UPDATE {{%prod_temp_images}} SET is_main=1 WHERE id=:id')->bindParam(':id', $id_img)->execute();
                     }
                 }
                 $vr['thumbUrl'] = Url::to($previewFolder['100'] . $fileName, true);
                 $vr['thumbUrl_100'] = Url::to($previewFolder['100'] . $fileName, true);
                 $vr['thumbUrl_300'] = Url::to($previewFolder['300'] . $fileName, true);
                 $vr['id'] = $id_img;
                 $vr['id_main'] = $mainImg['id'];
                 $vr['time']['start'] = $t_start;
                 $vr['time']['end'] = $t_end;
                 $vr['time']['diff'] = $t_end - $t_start;
             }
         }
     }
     $info[] = $vr;
     return json_encode(array('files' => $info));
 }
Example #21
0
    <?php 
echo $form->field($model, 'description')->textarea(['rows' => 6]);
?>
    <?php 
echo $form->field($model, 'file')->fileInput();
?>

<!--    --><?php 
//= $form->field($model, 'image')->textInput(['maxlength' => true])
//= $form->field($model, 'tags')->checkboxList(
//    ArrayHelper::map($tags, 'id', 'title')
//);
?>
    <?php 
echo $form->field($model, 'category_id')->label('Category')->dropDownList(Category::find()->select(['name', 'id'])->with('posts')->indexBy('id')->column(), ['prompt' => 'List of categories'])->hint('Choose the author');
?>
    <?php 
echo $form->field($model, 'author_id')->label('Author')->dropDownList(Author::find()->select(['name', 'id'])->with('posts')->indexBy('id')->column(), ['prompt' => 'List of authors'])->hint('Choose the author');
?>

<!--    --><?php 
//= $form->field($model, 'tags')->textInput(['maxlength' => true])
?>
<!--    --><?php 
//
//    echo "<pre>";
//    print_r($model->listTags);
//    echo "</pre>";
//    die();
//
Example #22
0
 /**
  * @return ActiveQuery
  */
 public function getCategory()
 {
     return $this->hasOne(Category::className(), ['id' => 'categoryID']);
 }
Example #23
0
 public static function getMenu($type)
 {
     return Category::find()->where(['menu' => $type])->orderBy('menu_position')->all();
 }
Example #24
0
/* @var $this yii\web\View */
/* @var $model frontend\models\Service */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="service-form">
    
    <?php 
$form = ActiveForm::begin([]);
?>
    
    <div class="row">
    
        <div class="col-md-6">
            <?php 
echo $form->field($model, 'category_id')->widget(Select2::classname(), ['language' => 'ru', 'data' => ArrayHelper::map(Category::find()->all(), 'id', 'name'), 'options' => ['placeholder' => 'Выберите состояние ...'], 'pluginOptions' => ['allowClear' => true]]);
?>
            
            <?php 
echo $form->field($model, 'owner')->widget(Select2::classname(), ['language' => 'ru', 'data' => ArrayHelper::map(User::find()->all(), 'id', 'username'), 'options' => ['placeholder' => 'Выберите состояние ...'], 'pluginOptions' => ['allowClear' => true]]);
?>
            <?php 
echo $form->field($model, 'can_reserve')->widget(SwitchInput::classname(), []);
?>
            <?php 
echo $form->field($model, 'status')->widget(SwitchInput::classname(), []);
?>
            <?php 
echo $form->field($model, 'longlat')->textInput(['maxlength' => true]);
?>
            <?php 
Example #25
0
<?php

use frontend\models\Category;
use frontend\models\Menu;
use yii\helpers\Html;
$firstRowCategories = Category::find()->where(['in', 'id', [33, 35, 38, 39]])->all();
$secondRowCategories = Category::find()->where(['in', 'id', [45, 46, 47, 48]])->all();
/** @var Category[] $firstRowCategories */
?>

<div id="gkBottomWrap" class="gkWrap clear">
    <div id="gkMiddleNav1" class="gkWrap">
        <ul class="menu">
            <?php 
foreach (Menu::findByAlias('top-menu-1')->items as $menuItem) {
    echo Html::tag('li', Html::a($menuItem->name, $menuItem->link));
}
?>
        </ul>
    </div>
    <div id="gkBottom1" class="gkWrap">
        <?php 
foreach ($firstRowCategories as $category) {
    ?>
        <div class="gkCol gkColRight">
            <div class="box nsp blue color_title small">
                <div>
                    <h3 class="header">
                        <span><?php 
    echo $category->title;
    ?>
Example #26
0
 public function getCategory($name = '经济d')
 {
     return $this->hasOne(Category::className(), ['id' => 'category_id'])->where(['title' => $name]);
 }
Example #27
0
 public function getCategory()
 {
     return Category::find()->where(['id' => $this->category_id])->one();
 }
Example #28
0
    ?>
<!--">Delete</a>-->
</span>
<span style="margin-left: 10px">
    <a class="btn btn-default" style="background-color: #d0eded" href="<?php 
    echo Yii::$app->urlManager->createUrl(['job/edit', 'id' => $job->id]);
    ?>
">Edit</a>
</span>
<?php 
}
if (!empty($job)) {
    ?>

<h3>From category: <?php 
    $category = Category::find()->where(['id' => $job->category_id])->one();
    echo $category->name;
    ?>
</h3>
<span style="font-size: 18px">Published: <?php 
    echo Job::dateVacancy($job);
    ?>
</span>
<h2 class="well"><?php 
    echo $job->title;
    ?>
<span style="font-size: 24px; color: green">    Salary: <?php 
    echo $job->salary;
    ?>
</span></h2>
<code style="font-size: 22px"><?php 
Example #29
0
 public function actionCategory($link)
 {
     $category = Category::findOne(['fullLink' => $link]);
     if (!$category) {
         if ($redirect = Redirect::findOne(['from' => $link])) {
             return \Yii::$app->response->redirect(yii\helpers\Url::to($redirect->to, true), 301)->send();
         }
         throw new NotFoundHttpException();
     }
     if (!empty($category->parentCategory)) {
         $this->getView()->params['breadcrumbs'][] = ['label' => $category->parentCategory->title, 'url' => yii\helpers\Url::toRoute(['/' . $category->parentCategory->fullLink], true)];
     }
     return $this->render('category', ['category' => $category, 'dataProvider' => new ActiveDataProvider(['query' => $category->getNews()->with('category'), 'sort' => ['defaultOrder' => ['publishDate' => SORT_DESC]], 'pagination' => ['pageSize' => 5]])]);
 }
Example #30
0
            </div>
        </div>
        <div class="box-content">
            <div class="row">
                <div class="items-form">

                    <?php 
$form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]);
?>

                    <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => true]);
?>

                    <?php 
echo $form->field($model, 'cat_id')->dropDownList(ArrayHelper::map(Category::find()->all(), 'id', 'name'), ['prompt' => '-- Выберите--'])->label('Категирия.  <a href="/category/create"> Создать</a>');
?>

                    <?php 
echo $form->field($model, 'brend_id')->dropDownList(ArrayHelper::map(Brend::find()->all(), 'id', 'name'), ['prompt' => '-- Выберите--'])->label('Производиетель звукоснимателя.  <a href="/brend/create"> Создать</a>');
?>

                    <?php 
echo $form->field($model, 'strings')->textInput(['maxlength' => true]);
?>

                    <?php 
echo $form->field($model, 'anker')->textInput(['maxlength' => true]);
?>

                    <?php