当前位置: 首页>>代码示例>>PHP>>正文


PHP models\Categories类代码示例

本文整理汇总了PHP中app\models\Categories的典型用法代码示例。如果您正苦于以下问题:PHP Categories类的具体用法?PHP Categories怎么用?PHP Categories使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Categories类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionCategory

 public function actionCategory()
 {
     for ($i = 1; $i <= 10; $i++) {
         $model = new Categories();
         $model->attributes = ['name' => 'Danh Mục Số ' . $i, 'title' => 'Title cua danh muc so ' . $i, 'slug' => 'danh-muc-so-' . $i, 'images' => '3.png', 'created_at' => time(), 'updated_at' => time()];
         $model->save();
     }
 }
开发者ID:lyhoi2204,项目名称:yii2,代码行数:8,代码来源:FakeController.php

示例2: save_category

 public function save_category(Request $request)
 {
     $category = new Categories();
     $category->category_name = $request->category_name;
     $category->category_description = $request->category_description;
     $category->publication_status = $request->publication_status;
     $category->save();
     Session::put('message', 'Save Category Information Successfully !');
     return redirect('/add-category');
 }
开发者ID:skyview059,项目名称:Laravel,代码行数:10,代码来源:SuperAdminController.php

示例3: getForm

 public function getForm($id = null)
 {
     $dataAdmin = new PrProviders();
     $modelProviders = new PrTypes();
     $modelCategories = new Categories();
     $listProviders = $modelProviders->where('flagactive', PrTypes::STATE_ACTIVE)->lists('name_type', 'id')->toArray();
     $listProviders = [null => 'Select un tipo'] + $listProviders;
     $listCategories = $modelCategories->where('flagactive', Categories::STATE_ACTIVE)->lists('name_category', 'id')->toArray();
     $listCategories = [null => 'Select una categoria'] + $listCategories;
     if (!is_null($id)) {
         $dataAdmin = PrProviders::find($id);
     }
     return viewc('admin.' . self::NAMEC . '.form', compact('dataAdmin', 'listProviders'), ['listCategories' => $listCategories, 'listCategories' => $listCategories]);
 }
开发者ID:josmel,项目名称:buen,代码行数:14,代码来源:ProviderWaitingController.php

示例4: actionCreate

 /**
  * Creates a new Resources model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($id)
 {
     if ($id == 0) {
         throw new \yii\web\BadRequestHttpException("Неправильный запрос");
     }
     $model = new Categories();
     $model->parent_id = $id;
     $model->handler = $this->id;
     $model->attachBehavior('createStoreDir', ['class' => StoreDirBehavior::className(), 'handlerName' => $this->id]);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['list', 'id' => $model->parent_id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
开发者ID:kintastish,项目名称:mobil_old,代码行数:20,代码来源:ImageController.php

示例5: rules

 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     $dataCategory = Categories::whereFlagactive(1)->lists('id')->toArray();
     $listCategory = implode(",", $dataCategory);
     $rules = ['description' => 'required', 'pu_category_id' => "required|in:{$listCategory}", 'name_provider' => 'required', 'email' => 'required:unique:pr_providers,email', 'phone' => 'required'];
     return $rules;
 }
开发者ID:josmel,项目名称:buen,代码行数:12,代码来源:RegisterProviderRequest.php

示例6: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::create();
     $categories = Categories::where('parent_id', '>=', 0)->get();
     $baseUrl = 'http://7xkn9n.com1.z0.glb.clouddn.com/img/';
     $string = file_get_contents(__DIR__ . "/../data/products.json");
     $products = json_decode($string, true);
     $cate_ids = [];
     foreach ($categories as $category) {
         $cate_ids[] = $category->id;
     }
     foreach ($products as $productData) {
         try {
             $name = $productData['meta']['title'];
             $content = '';
             if (isset($productData['content'])) {
                 $content = str_replace('<h2 class="title">百科词条</h2>', '', $productData['content']);
             }
             $klass = $productData['meta']['class']['text'];
             $category = Categories::where('name', $klass)->get();
             $description = substr($content, 0, 100);
             $cid = $faker->randomElement($cate_ids);
             if ($category->count() == 1) {
                 $cid = $category[0]->id;
             }
             $pieces = preg_split("/\\//i", $productData['meta']['image']);
             $product = Product::create(['name' => $name, 'slug' => $name, 'description' => $description, 'keywords' => $klass, 'cover' => $baseUrl . $pieces[count($pieces) - 1], 'category_id' => $cid, 'user_id' => 1]);
             $detailTopic = Topic::create(['title' => $name, 'slug' => $name, 'product_id' => $product->id, 'user_id' => 1, 'keywords' => $name, 'description' => $description, 'content' => $content, 'is_product_detail_topic' => true]);
             $product->detail_topic_id = $detailTopic->id;
             $product->save();
         } catch (Exception $e) {
             throw $e;
         }
     }
 }
开发者ID:jiketao,项目名称:jiketao-laravel,代码行数:40,代码来源:ProductsTableSeeder.php

示例7: compose

 public function compose(View $view)
 {
     $categories = \App\Models\Categories::i()->withPostsCount();
     $posts_count = \App\Models\Posts::active()->count();
     $view->with('categories', $categories);
     $view->with('posts_count', $posts_count);
 }
开发者ID:vitos8686,项目名称:0ez,代码行数:7,代码来源:CategoriesMenuComposer.php

示例8: upload

 public function upload()
 {
     if ($this->validate()) {
         $cat = Categories::findOne($this->id);
         $contr = Yii::$app->controllerNamespace . '\\' . ucfirst($cat->handler) . 'Controller';
         $base = $contr::baseStorePath();
         $store_to = $base['real'] . $cat->route;
         foreach ($this->files as $f) {
             $new_fn = $this->newFileName($f->baseName, $f->extension);
             if ($f->saveAs($store_to . $new_fn)) {
                 $res = new Resources();
                 $res->attachBehavior('ImageBehavior', ['class' => ImageBehavior::className()]);
                 $res->category_id = $this->id;
                 $res->title = $res->description = $f->baseName;
                 $res->keywords = $new_fn;
                 //реальное имя файла с расширением
                 $res->alias = str_replace('.' . $f->extension, '', $new_fn);
                 //псевдоним изначально равен имени файла
                 $res->path = $store_to;
                 $res->webroute = $base['web'] . $cat->route;
                 $res->filename = $new_fn;
                 $res->save();
             }
             //TODO обработка ошибки сохранения файла
         }
         return true;
     }
     return false;
 }
开发者ID:kintastish,项目名称:mobil_old,代码行数:29,代码来源:FileUploadModel.php

示例9: rules

 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     $dataCategory = Categories::whereFlagactive(1)->lists('id')->toArray();
     $listCategory = implode(",", $dataCategory);
     $rules = ['description' => 'required', 'pu_category_id' => "required|in:{$listCategory}"];
     return $rules;
 }
开发者ID:josmel,项目名称:buen,代码行数:12,代码来源:RegisterPublicationRequest.php

示例10: index

 public function index($slug = '')
 {
     if ($slug != '') {
         $category = Categories::i()->getBySlug($slug);
         if (empty($category)) {
             abort(404);
         }
         $category_id = $category->id;
         view()->share('active_category', $category_id);
         view()->share('seo_title', 'Категория: ' . $category->seo_title);
         view()->share('seo_description', $category->seo_description);
         view()->share('seo_keywords', $category->seo_keywords);
         Title::prepend('Категория');
         Title::prepend($category->seo_title);
     } else {
         Title::append(Conf::get('seo.default.seo_title'));
         $category = null;
         $category_id = null;
     }
     $q = request('q', null);
     if (!empty($q)) {
     }
     $posts = Posts::i()->getPostsByCategoryId($category_id, $q);
     $data = ['posts' => $posts, 'category' => $category, 'q' => $q, 'title' => Title::renderr(' : ', true)];
     return view('site.posts.index', $data);
 }
开发者ID:garf,项目名称:0ez,代码行数:26,代码来源:PostsController.php

示例11: edit

 /**
  * @param $id
  */
 public static function edit($id)
 {
     $post = Posts::findByPK($id);
     if (!Request::is_authenticated()) {
         Session::push('flash-message', 'You must login before!');
         Response::redirect('login?next=post/edit/' . $id);
     } else {
         if (Request::user()->id !== $post['id_account']) {
             Session::push('flash-message', 'You does not have permission to edit the other Member\'s post!');
             Response::redirect('');
         }
     }
     if ("POST" == Request::method()) {
         $id_member = Request::user()->id;
         $data = Request::POST()->post;
         $title = Request::POST()->title;
         $cat = Request::POST()->category;
         Posts::edit($id, $id_member, $title, $data, $cat);
         # set flash messages
         Session::push('flash-message', 'Your post has changed successfully!');
         Response::redirect('post/read/' . $id);
     } else {
         $users = Accounts::find(['type' => 2]);
         $categories = Categories::all();
         View::render('member/edit-post', ['post' => $post, 'users' => $users, 'categories' => $categories]);
     }
 }
开发者ID:OckiFals,项目名称:iniforum,代码行数:30,代码来源:PostsController.php

示例12: showCategoriesProducts

 public function showCategoriesProducts($id)
 {
     $category = Categories::findOrFail($id);
     $active_menu = '';
     $products = Product::getProductInCategory($id);
     return view('category', compact(['category', 'active_menu', 'products']));
 }
开发者ID:jiketao,项目名称:jiketao-laravel,代码行数:7,代码来源:PagesController.php

示例13: buildItems

 private function buildItems()
 {
     $tpl = $this->_config['itemTemplate'];
     $hasParams = preg_match('/@\\d+@/', $tpl) != false;
     Yii::trace('hasParams=' . $hasParams);
     $cats = Categories::findAll(array_keys($this->_config['filterCategories']));
     foreach ($cats as $c) {
         if (!$c->isEmpty) {
             foreach ($c->resources as $r) {
                 $t = $tpl;
                 if ($hasParams) {
                     $params = $r->getParams();
                     if ($params !== null) {
                         $search = $replace = [];
                         foreach ($params as $p) {
                             $search[] = '@' . $p->type_id . '@';
                             $replace[] = $p->value;
                         }
                         $t = str_replace($search, $replace, $t);
                         $t = preg_replace('/@\\d+@/', '', $t);
                         //удаление лишних/не найденных
                     }
                 }
                 $this->_items[] = str_replace($this->_ph, [$r->id, $r->created, $r->alias, $r->title, $r->description, '/' . $r->route], $t);
             }
         }
     }
     return implode('', $this->_items);
 }
开发者ID:kintastish,项目名称:mobil,代码行数:29,代码来源:LinkListWidget.php

示例14: getForm

 public function getForm($id = null, $modulo = null)
 {
     $modelCategories = new Categories();
     $listTypes = PuTypes::whereFlagactive(PuTypes::STATE_ACTIVE)->lists('name_type', 'id')->toArray();
     $listTypes = [null => 'Select un tipo'] + $listTypes;
     $listCategories = $modelCategories->where('flagactive', Categories::STATE_ACTIVE)->lists('name_category', 'id')->toArray();
     $listCategories = [null => 'Select una categoria'] + $listCategories;
     $dataPost = PuAds::find($id);
     if (!is_null($id)) {
         $dataPost = PuAds::find($id);
         $dataPicture = PuPicture::wherePuAdId($id)->first();
         $dataPost->picture = !empty($dataPicture->url) ? "{$dataPost->picture}" : null;
         $dataPost->pr_provider_id = !empty($dataPost->pr_provider_id) ? "{$dataPost->pr_provider_id}" : 0;
     }
     return viewc('admin.' . self::NAMEC . '.form', compact('dataPost', 'modulo'), ['listCategories' => $listCategories, 'listTypes' => $listTypes]);
 }
开发者ID:josmel,项目名称:buen,代码行数:16,代码来源:PublicationController.php

示例15: parseData

 /**
  * Reads file content and convert into array or object
  * 
  * @params string	$filePath
  * @return object
  *  
  */
 private function parseData($filePath)
 {
     $catID = \app\models\Categories::getCategoryID('Construction');
     $content = file_get_contents($filePath);
     $data = array_map('str_getcsv', file($filePath));
     array_walk($data, function (&$a) use($data) {
         $a = array_combine($data[0], $a);
     });
     array_shift($data);
     $parsedData = array();
     foreach ($data as $key => $item) {
         $parsedData[$key] = (object) array();
         $parsedData[$key]->date = date("Y-m-d", strtotime($item['date']));
         $parsedData[$key]->lot_title = $item['lot title'];
         $parsedData[$key]->lot_location = $item['lot location'];
         $parsedData[$key]->pre_tax_amount = $item['pre-tax amount'];
         $parsedData[$key]->tax_amount = $item['tax amount'];
         $parsedData[$key]->category = \app\models\Categories::getCategoryID($item['category']);
         $parsedData[$key]->lot_condition = \app\models\LotCondition::getLotConditionID($item['lot condition']);
         $parsedData[$key]->tax_name = \app\models\TaxName::getTaxNameID($item['tax name']);
         if (is_null($parsedData[$key]->category)) {
             // category does not exist, so add it
             $parsedData[$key]->category = \app\models\Categories::addCategory($item['category']);
         }
         if (is_null($parsedData[$key]->lot_condition)) {
             // lot condition does not exist, so add it
             $parsedData[$key]->lot_condition = \app\models\LotCondition::addLotCondition($item['lot condition']);
         }
         if (is_null($parsedData[$key]->tax_name)) {
             // tax name does not exist, so add it
             $parsedData[$key]->tax_name = \app\models\TaxName::addTaxName($item['tax name']);
         }
     }
     return $parsedData;
 }
开发者ID:noldsel,项目名称:webdev-challenge,代码行数:42,代码来源:InventoryController.php


注:本文中的app\models\Categories类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。