/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $type = new Type();
     $type->title = 'Post';
     $type->slug = 'Posts';
     $type->description = 'Create a blog post.';
     $type->save();
     $type = new Type();
     $type->title = 'Page';
     $type->slug = 'Pages';
     $type->description = 'Create a page.';
     $type->save();
     $type = new Type();
     $type->title = 'Project';
     $type->slug = 'Projects';
     $type->description = 'Create a project post.';
     $type->save();
     $type = new Type();
     $type->title = 'Product';
     $type->slug = 'Products';
     $type->description = 'Create a product';
     $type->save();
     $type = new Type();
     $type->title = 'Publication';
     $type->slug = 'Publications';
     $type->description = 'Create a book project.';
     $type->save();
 }
示例#2
0
 public function actionType()
 {
     for ($i = 1; $i <= 90; $i++) {
         $model = new Type();
         $model->attributes = ['name' => 'Type Số ' . $i, 'title' => 'Title cua Type so ' . $i, 'categories_id' => rand(1, 10), 'slug' => 'type-so-' . $i, 'images' => '3.png', 'created_at' => time(), 'updated_at' => time()];
         $model->save();
     }
 }
示例#3
0
 public function actionType($id)
 {
     $modelType = new Type();
     $modelProduct = new Product();
     foreach ($modelType->getType($id) as $type) {
         $typeName = $type;
     }
     $products = $modelProduct->getWithType($typeName);
     return $this->render('type', ['products' => $products, 'typeName' => $typeName]);
 }
示例#4
0
 public function actionIndex()
 {
     $model = new Discuss();
     $arr['forum'] = $model->getAll();
     $user = new User();
     $type = new Type();
     foreach ($arr['forum'] as $k => $v) {
         $arr['forum'][$k]['addtime'] = date('Y-m-d H:i:s', $arr['forum'][$k]['addtime']);
         $arr['forum'][$k]['author_id'] = substr($arr['forum'][$k]['author_id'] . 'a', 0, -1);
         $arr['forum'][$k]['author_id'] = $user->getUsername(['_id' => $arr['forum'][$k]['author_id']]);
         $arr['forum'][$k]['for_type'] = $type->getAll(['_id' => $arr['forum'][$k]['for_type']]);
     }
     return $this->renderPartial('index', $arr);
 }
示例#5
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     //
     $type = \App\Models\Type::find($id);
     return view('types', ['type' => $type]);
     // return view('types',compact("type"));  same as previos
 }
 public function edit($id)
 {
     $brands = Brand::orderBy('sort_order')->get();
     $categories = $this->get_categories();
     $types = Type::with('attributes')->get();
     $good = Good::with('good_attrs', 'good_galleries')->find($id);
     return view('admin.good.edit', ['good' => $good, 'brands' => $brands, 'categories' => $categories, 'types' => $types]);
 }
 public function edit($id)
 {
     $category = Category::find($id);
     $types = Type::with("attributes")->get();
     $categories = $this->get_categories();
     $category->filter_attr = Attribute::with('type.attributes')->whereIn('id', unserialize($category->filter_attr))->get();
     return view('admin.category.edit', ['category' => $category, 'categories' => $categories, 'types' => $types]);
 }
示例#8
0
 protected function findModel($id)
 {
     if (($model = Type::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
示例#9
0
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create()
 {
     //获取商品类型
     $type_list = Type::all();
     //获取商品分类
     $categoryData = Category::get();
     $cate_list = getTree($categoryData);
     return view('admin.goods.create', compact('type_list', 'cate_list'));
 }
示例#10
0
 public function search(Request $request, $type_id)
 {
     $types = Type::all();
     $keyword = "%" . $request->keyword . "%";
     //        return $keyword;
     $attributes = Attribute::with('type')->where('name', 'like', $keyword)->paginate(config('wyshop.page_size'));
     //        return $attributes;
     return view('admin.attribute.index', ['types' => $types, 'type_id' => $type_id, 'attributes' => $attributes]);
 }
示例#11
0
 /**
  * Updates an existing Product model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $this->checkLogin();
     $this->layout = 'admin';
     $model = $this->findModel($id);
     $modelType = new Type();
     $allType = $modelType->getAllType();
     if ($model->load(Yii::$app->request->post())) {
         $model->image = UploadedFile::getInstances($model, 'image');
         foreach ($model->image as $file) {
             $file->saveAs('images/' . $file->baseName . '.' . $file->extension);
             $images[] = $file->baseName . '.' . $file->extension;
         }
         $model->image = implode(',', $images);
         $model->save();
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model, 'allType' => $allType]);
     }
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Type::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])->andFilterWhere(['like', 'name_eng', $this->name_eng]);
     return $dataProvider;
 }
示例#13
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Type::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_type' => $this->id_type]);
     $query->andFilterWhere(['like', 'desc_type', $this->desc_type])->andFilterWhere(['like', 'hexcolor_type', $this->hexcolor_type])->andFilterWhere(['like', 'icon_type', $this->icon_type]);
     return $dataProvider;
 }
示例#14
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Type::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, 'category_id' => $this->category_id, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'images', $this->images])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'seo_keywords', $this->seo_keywords])->andFilterWhere(['like', 'seo_title', $this->seo_title]);
     return $dataProvider;
 }
示例#15
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Type::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]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
示例#16
0
 /**
  * This command echoes what you have entered as the message.
  * @param string $message the message to be echoed.
  */
 public function actionKhoahoctv()
 {
     for ($i = 16655; $i <= 70000; $i++) {
         $crawler = new Crawl();
         $crawler->arr_att_clean = array('script', '.thumblock');
         $url = 'http://khoahoc.tv/quan-the-tu-vien-meteora-' . $i;
         $namepath = '/html/body/div[1]/div[3]/div[1]/h1';
         $contentpath = '/html/body/div[1]/div[3]/div[1]/div[3]';
         $type_path = '/html/body/div[1]/div[3]/div[1]/div[2]/span[3]/a';
         if (!@($name = $crawler->getTitle($url, $namepath))) {
             echo 'error_' . $i . "\n";
         } else {
             $name = rUrl::utf8($crawler->getTitle($url, $namepath));
             $content = $crawler->getTitle($url, $contentpath);
             $type = $crawler->getTitle($url, $type_path);
             $content = $crawler->removeLink($content);
             $images = $crawler->getImagesFromMeta($url);
             $keywords = $crawler->getKeywords($url);
             $descriptionmeta = $crawler->getDescriptionmeta($url);
             $type_slug = rUrl::slug($type);
             $mType = Type::find()->Where(['LIKE', 'slug', $type_slug])->one();
             $id_type = $mType['id'];
             $slug = rUrl::slug($name);
             if ($id_type !== null) {
                 $id_type = $mType['id'];
             } else {
                 $id_type = 22;
             }
             $model = new News();
             $model->attributes = ['name' => $name, 'slug' => $slug, 'images' => $images, 'description' => $content, 'seo_keywords' => $keywords, 'view_count' => rand(1000, 10000), 'source' => 'kh', 'seo_title' => $descriptionmeta, 'type_id' => $id_type, 'user_id' => 1, 'hot' => 0, 'post_final' => $i, 'created_at' => time(), 'updated_at' => time()];
             $model->save();
             echo "ok_" . $i . "\n";
             // exit();
         }
     }
 }
示例#17
0
 <!-- World News -->
<?php 
use app\models\News;
use app\models\Type;
use yii\helpers\Url;
?>
            <?php 
foreach (Type::all() as $itemtype) {
    ?>
                    <div class="column-two-third">
                        <h5 class="line">
                            <span><?php 
    echo $itemtype->name;
    ?>
</span>
                            <div class="navbar">
                                <a id="next2" class="next" href="#"><span></span></a>   
                                <a id="prev2" class="prev" href="#"><span></span></a>
                            </div>
                        </h5>
                        
                        <div class="outerwide" >
                            <ul class="wnews" id="carousel2">
                            <?php 
    foreach (News::fromType($itemtype->id) as $item) {
        ?>
                                <li>
                                    <img src="<?php 
        echo $item->images;
        ?>
" width="300" height="162" alt="MyPassion" class="alignleft" />
 public function associateIdType($type, $advertisement)
 {
     return $advertisement->type()->associate(Type::findOrFail($type));
 }
示例#19
0
 public function destroy($id)
 {
     Type::destroy($id);
     return back();
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     if (Session::get('level') == '1' || Session::get('level') == '2' && Session::get('fingerprint') == md5($_SERVER['HTTP_USER_AGENT'] . $_SERVER['REMOTE_ADDR'])) {
         $Type = Type::find(e($id));
         DB::transaction(function () use($Type) {
             Type::find($Type->id)->delete();
         });
         return Redirect::to('type');
     } else {
         return Redirect::to('/');
     }
 }
示例#21
0
 /**
  * edit data page
  * @param int id
  * @return view
  */
 public function edit($id)
 {
     $type = Type::all();
     $attribute = Attribute::findOrFail($id);
     return view('admin.attribute.edit', compact('attribute', 'type'));
 }
示例#22
0
 public function run()
 {
     Type::create(['name' => 'Kitchen']);
     Type::create(['name' => 'Friteuse']);
     Type::create(['name' => 'Kiosk']);
 }
示例#23
0
 public function getType($id)
 {
     return Type::find('name')->where(['id' => $id])->one();
 }
 public function edit($type_id, $id)
 {
     $types = Type::all();
     $attribute = Attribute::find($id);
     return view('admin.attribute.edit', ['types' => $types, 'type_id' => $type_id, 'attribute' => $attribute]);
 }
示例#25
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit(Request $request, $id)
 {
     // find a single resource by ID
     $output = DefaultItem::find($id);
     if ($output) {
         // get list of possible service types
         $types = Type::all();
         // Get full list of default items
         $default_items = DefaultItem::with('type')->orderBy('type_id')->orderBy('seq_no');
         return view($this->view_one, array('default_item' => $output, 'types' => $types, 'default_items' => $default_items->get()));
     }
     //
     $message = 'Error! DefaultItem with id "' . $id . '" not found';
     return \Redirect::route($this->view_idx)->with(['status' => $message]);
 }
示例#26
0
    // 	"lastname"=>"Jai",
    // 	"email"=>"*****@*****.**",
    // 	"password"=>"bla"
    // 	]);
    // return $user;
});
Route::get('about', "PagesController@showAbout");
Route::get('contact', "PagesController@showContact");
Route::get('login', "LoginController@showLoginForm");
Route::post('login', "LoginController@processLogin");
Route::get('logout', "LoginController@logout");
Route::get('cart', "CartController@showCart");
Route::post('cartItems', "CartController@addItem");
Route::post('orders', "CartController@checkout");
Route::get('types/{id}', function ($id) {
    // create types controller and put it under show//
    $type = \App\Models\Type::find($id);
    return view('types', ['type' => $type]);
    // return view('types',compact("type")); same thing as above
});
// Route::get('products/create',"ProductsController@create");
// Route::post('products', "ProductsController@store");
// Route::get('products/{id}/edit',"ProductsController@edit");
// Route::put('products/{id}',"ProductsController@update");
Route::resource('products', 'ProductsController');
// Route::get('users/create', "UsersContollers@create");
// Route::get('users/{id}',"UsersContollers@show");
// Route::post('users',"UsersContollers@store");
// Route::get('users/{id}/edit',"UsersContollers@edit"
// Route::put('users/{id}',"UsersContollers@update"
Route::resource('users', 'UsersController');
示例#27
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     //
     // find a single resource by ID
     $output = Type::find($id);
     if ($output) {
         $plans = $output->plans()->get();
         if (count($plans)) {
             flashError('Type "' . $output->name . '" is still referred by Plans and cannot be deleted.');
             return redirect()->back();
         }
         $output->delete();
         $message = 'Type with id "' . $id . '" deleted.';
         return \Redirect::route('types.index')->with(['status' => $message]);
     }
     //
     $message = 'Error! Type with ID "' . $id . '" not found';
     return \Redirect::route('types.index')->with(['status' => $message]);
 }
示例#28
0
 public function getType()
 {
     return $this->hasOne(Type::className(), ['id_type' => 'type_id']);
 }
示例#29
0
    if ($item->id == Yii::$app->request->get('id') && !Yii::$app->request->get('type')) {
        echo 'class="current"';
    }
    ?>
>
                            	<a href="<?php 
    echo Url::to(['site/category', 'slug' => $item->slug, 'id' => $item->id]);
    ?>
"><?php 
    echo $item->name;
    ?>
</a>
                                
                                <ul style="width:200px;">
                                    <?php 
    foreach (Type::find()->where(['category_id' => $item->id, 'display' => MyDefine::yes])->all() as $rows) {
        ?>
                                        
                                        <li><i class="icon-right-open"></i><a href="<?php 
        echo Url::to(['site/type', 'type' => $rows->slug, 'slug' => $item->slug, 'id' => $rows->id]);
        ?>
"><?php 
        echo $rows->name;
        ?>
</a></li>
                                        
                                    <?php 
    }
    ?>
                                </ul>
                                
echo Html::submitButton('Գեներացնել (Generate)', ['class' => 'btn btn-primary']);
?>


<?php 
ActiveForm::end();
?>

<div class="site-index" style="width: 3500px;">

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\ActionColumn', 'template' => '{update}{delete}', 'urlCreator' => function ($action, $model, $key, $index) {
    if ($action === 'update') {
        $arrayParams = ['MainSearch' => ['region' => $model->region]];
        $arrayParams['id'] = $model->id;
        $params = array_merge(["site/main"], $arrayParams);
        $url = Yii::$app->urlManager->createUrl($params);
        return $url;
    }
    if ($action === 'delete') {
        $arrayParams = ['MainSearch' => ['region' => $model->region], 'id' => $model->id];
        $params = array_merge(["site/delete"], $arrayParams);
        $url = Yii::$app->urlManager->createUrl($params);
        return $url;
    }
}], ['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'city', 'value' => 'city0.nameBothShort', 'filter' => Html::activeDropDownList($searchModel, 'city', ArrayHelper::map(City::find()->all(), 'id', 'nameBothShort'), ['class' => 'form-control', 'prompt' => 'Select Category'])], ['attribute' => 'type', 'value' => 'type0.nameBothShort', 'filter' => Html::activeDropDownList($searchModel, 'type', ArrayHelper::map(Type::find()->all(), 'id', 'nameBothShort'), ['class' => 'form-control', 'prompt' => 'Select Category'])], 'resident', 'children', 'employee', 'retiree', ['attribute' => 'dominant', 'value' => 'dominant0.nameBothShort', 'filter' => Html::activeDropDownList($searchModel, 'retiree', ArrayHelper::map(Dominant::find()->all(), 'id', 'nameBothShort'), ['class' => 'form-control', 'prompt' => 'Select Category'])], ['attribute' => 'mainTrashPlaces.trash_place_id', 'value' => 'trashPlaceMulti', 'filter' => Html::activeDropDownList($searchModel, 'mainTrashPlaces.trash_place_id', ArrayHelper::map(TrashPlace::find()->all(), 'id', 'nameBothShort'), ['class' => 'form-control', 'prompt' => 'Select Category']), 'contentOptions' => ['style' => 'width: ' . $width . ';']], ['attribute' => 'mainTrashMen.trash_man_id', 'value' => 'trashManMulti', 'filter' => Html::activeDropDownList($searchModel, 'mainTrashMen.trash_man_id', ArrayHelper::map(TrashMan::find()->all(), 'id', 'nameBothShort'), ['class' => 'form-control', 'prompt' => 'Select Category']), 'contentOptions' => ['style' => 'width: ' . $width . ';']], ['attribute' => 'filter_trash_out', 'value' => 'trash_out', 'filter' => Html::activeDropDownList($searchModel, 'filter_trash_out', array('1' => '1-5', '2' => '6-10', '3' => '11-20', '4' => '20+'), ['class' => 'form-control', 'prompt' => 'Select Category'])], ['attribute' => 'filter_trash_count', 'value' => 'trash_count', 'filter' => Html::activeDropDownList($searchModel, 'filter_trash_count', array('1' => '1-5', '2' => '6-10', '3' => '11-20', '4' => '20+'), ['class' => 'form-control', 'prompt' => 'Select Category'])], ['attribute' => 'filter_summer_1', 'value' => 'summer_count_1', 'filter' => Html::activeDropDownList($searchModel, 'filter_summer_1', array('1' => '1-5', '2' => '6-10', '3' => '11-20', '4' => '20+'), ['class' => 'form-control', 'prompt' => 'Select Category'])], ['attribute' => 'filter_summer_2', 'value' => 'summer_count_2', 'filter' => Html::activeDropDownList($searchModel, 'filter_summer_2', array('1' => '1-5', '2' => '6-10', '3' => '11-20', '4' => '20+'), ['class' => 'form-control', 'prompt' => 'Select Category'])], ['attribute' => 'filter_summer_3', 'value' => 'summer_count_3', 'filter' => Html::activeDropDownList($searchModel, 'filter_summer_3', array('1' => '1-5', '2' => '6-10', '3' => '11-20', '4' => '20+'), ['class' => 'form-control', 'prompt' => 'Select Category'])], ['attribute' => 'filter_summer_4', 'value' => 'summer_count_4', 'filter' => Html::activeDropDownList($searchModel, 'filter_summer_4', array('1' => '1-5', '2' => '6-10', '3' => '11-20', '4' => '20+'), ['class' => 'form-control', 'prompt' => 'Select Category'])], ['attribute' => 'filter_winter_1', 'value' => 'winter_count_1', 'filter' => Html::activeDropDownList($searchModel, 'filter_winter_1', array('1' => '1-5', '2' => '6-10', '3' => '11-20', '4' => '20+'), ['class' => 'form-control', 'prompt' => 'Select Category'])], ['attribute' => 'filter_winter_2', 'value' => 'winter_count_2', 'filter' => Html::activeDropDownList($searchModel, 'filter_winter_2', array('1' => '1-5', '2' => '6-10', '3' => '11-20', '4' => '20+'), ['class' => 'form-control', 'prompt' => 'Select Category'])], ['attribute' => 'filter_winter_3', 'value' => 'winter_count_3', 'filter' => Html::activeDropDownList($searchModel, 'filter_winter_3', array('1' => '1-5', '2' => '6-10', '3' => '11-20', '4' => '20+'), ['class' => 'form-control', 'prompt' => 'Select Category'])], ['attribute' => 'filter_winter_4', 'value' => 'winter_count_4', 'filter' => Html::activeDropDownList($searchModel, 'filter_winter_4', array('1' => '1-5', '2' => '6-10', '3' => '11-20', '4' => '20+'), ['class' => 'form-control', 'prompt' => 'Select Category'])], ['attribute' => 'paper', 'value' => 'paper0.nameBothShort', 'filter' => Html::activeDropDownList($searchModel, 'paper', ArrayHelper::map(Paper::find()->all(), 'id', 'nameBothShort'), ['class' => 'form-control', 'prompt' => 'Select Category']), 'contentOptions' => ['style' => 'width: ' . $width . ';']], ['attribute' => 'mainTrashRelations.trash_relation_id', 'value' => 'trashRelationMulti', 'filter' => Html::activeDropDownList($searchModel, 'mainTrashRelations.trash_relation_id', ArrayHelper::map(TrashRelation::find()->all(), 'id', 'nameBothShort'), ['class' => 'form-control', 'prompt' => 'Select Category']), 'contentOptions' => ['style' => 'width: ' . $width . ';']], ['attribute' => 'mainTrashRecycles.trash_recycle_id', 'value' => 'trashRecycleMulti', 'filter' => Html::activeDropDownList($searchModel, 'mainTrashRecycles.trash_recycle_id', ArrayHelper::map(TrashRecycle::find()->all(), 'id', 'nameBothShort'), ['class' => 'form-control', 'prompt' => 'Select Category'])], ['attribute' => 'mainRubberItems.rubber_item_id', 'value' => 'rubberItemsMulti', 'filter' => Html::activeDropDownList($searchModel, 'mainRubberItems.rubber_item_id', ArrayHelper::map(RubberItems::find()->all(), 'id', 'nameBoth'), ['class' => 'form-control', 'prompt' => 'Select Category'])], 'answer_count', 'woman_count', ['attribute' => 'person', 'value' => 'person0.nameBothShort', 'filter' => Html::activeDropDownList($searchModel, 'person', ArrayHelper::map(Person::find()->all(), 'id', 'nameBothShort'), ['class' => 'form-control', 'prompt' => 'Select Category'])], 'date', 'interrogatory']]);
?>


</div>