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


PHP Categories::create方法代码示例

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


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

示例1: postForm

 public function postForm(FormCategoryRequest $request)
 {
     if (!empty($request)) {
         $pathImage = $request->get('picture', null);
         $data = $request->all();
         if ($request->hasfile('picture')) {
             $validator = Validator::make($request->all(), ['picture' => ['mimes:jpg,png,jpeg']]);
             if ($validator->fails()) {
                 return redirect(action('Admin\\CategoryController@postForm'))->withErrors($validator)->withInput();
             }
             $file = $request->file('picture');
             $nameimage = date('Ymdhis') . rand(1, 1000) . '.' . $file->getClientOriginalExtension();
             $file->move(public_path() . "/dinamic/category/", $nameimage);
             $pathImage = '/dinamic/category/' . $nameimage;
             $data['picture'] = $pathImage;
         }
         $data['flagactive'] = $request->get('flagactive', 1);
         if ($request->id) {
             $obj = Categories::find($request->id);
             $obj->update($data);
             $idTips = $obj->id;
         } else {
             $obj = Categories::create($data);
             $idTips = $obj->id;
         }
         return redirect('admpanel/' . self::NAMEC)->with('messageSuccess', 'Caracteristicas Guardado');
     }
     return redirect('admpanel')->with('messageError', 'Error al guardar el tip');
 }
开发者ID:josmel,项目名称:buen,代码行数:29,代码来源:CategoryController.php

示例2: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $categories = ['shoujitongxun' => ['display_name' => '手机通讯', 'sub' => [['zhinengshouji', '智能手机'], ['feizhinengshouji', '非智能手机'], ['duijiangji', '对讲机'], ['lanyaerji', '蓝牙耳机']]], 'sheyingshexiang' => ['display_name' => '摄影摄像', 'sub' => [['danfangjisheng', '单反机身'], ['weidanxiangji', '微单相机'], ['shumaxiangji', '数码相机'], ['jiayongshexiangji', '家用摄像机'], ['zhuanyeshexiangji', '专业摄像机']]], 'xiangjipeijian' => ['display_name' => '相机配件', 'sub' => [['shumapeijian', '数码配件'], ['chongdianqi', '充电器'], ['dianchi', '电池'], ['diannaozhijia', '电脑支架'], ['yidongdianyuan', '移动电源'], ['chukongbi', '触控笔'], ['qitashumapeijian', '其它数码配件']]]];
     foreach ($categories as $name => $category) {
         $parent = Categories::create(['slug' => $name, 'name' => $category['display_name'], 'parent_id' => -1]);
         $subs = $category['sub'];
         foreach ($subs as $sub_category) {
             Categories::create(['slug' => $sub_category[0], 'name' => $sub_category[1], 'parent_id' => $parent->id]);
         }
     }
 }
开发者ID:jiketao,项目名称:jiketao-laravel,代码行数:16,代码来源:CategoriesTableSeeder.php

示例3: store

 public function store($request)
 {
     $cacheTag = ['categories'];
     $validator = $this->validate($request);
     if (!$validator->fails()) {
         Logs::create(['activity' => 'store', 'module' => 'categories']);
         Cache::tags($cacheTag)->flush();
         $request['company_id'] = config('global.companies.current.id');
         return Categories::create($request);
     } else {
         return new \Exception($validator->errors()->first());
     }
 }
开发者ID:PingadoWeb,项目名称:deliveryApi,代码行数:13,代码来源:CategoriesRepository.php

示例4: create

 public function create()
 {
     if (Request::isMethod('get')) {
         $data['page_title'] = 'Data Kategori';
         return view('categories.create', $data);
     } else {
         if (Request::isMethod('post')) {
             $nama = Input::get('nama');
             $kode = Input::get('kode');
             $item = array('name' => $nama);
             Categories::create($item);
             return redirect('categories');
         }
     }
 }
开发者ID:freyandhy,项目名称:pos_project,代码行数:15,代码来源:CategoriesController.php

示例5: store

 public function store()
 {
     $name = Input::has("name") ? Input::get("name") : "";
     $lang = Input::get("lang");
     $name_lang = Input::has("name_lang") ? Input::get("name_lang") : "";
     if ($name == "") {
         Session::flash("error", trans("categories.notifications.field_name_missing"));
         return Redirect::to("/categories/create")->withInput();
     }
     $category_id = Categories::create(array('name' => $name));
     //dd($lang, $name_lang,$category_id->id ); exit;
     if ($lang != "en" && $name_lang != " ") {
         AppCategoriesI18n::create(array('category_id' => $category_id->id, 'lang' => $lang, 'name' => $name_lang));
     }
     Session::flash('success', trans("categories.notifications.register_successful"));
     return Redirect::to("/categories");
 }
开发者ID:devchd,项目名称:metronic,代码行数:17,代码来源:CategoriesController.php

示例6: add

 public static function add()
 {
     if (!Request::is_admin()) {
         Response::redirect('');
     }
     if ("POST" == Request::method()) {
         $id_acc = Request::user()->id;
         $name = Request::POST()->name;
         $decsription = Request::POST()->description;
         Categories::create($id_acc, $name, $decsription);
         # push flash-message
         Session::push('flash-message', 'That category has successfuly added!');
         Response::redirect('categories');
     } else {
         $categories = Categories::all()->fetchAll(\PDO::FETCH_CLASS);
         View::render('categories/add', ['categories' => $categories]);
     }
 }
开发者ID:OckiFals,项目名称:iniforum,代码行数:18,代码来源:CategoriesController.php

示例7: newCategory

 public function newCategory($id)
 {
     if ($_POST) {
         $request = (object) $_POST;
         $category = new Categories();
         if (isset($id)) {
             $category->update($id, $request->nombre, $request->descripcion);
             newFlashMessage('test', 'Categoria ' . ucwords($request->nombre) . " actualizada.");
             return redirect('admin/category');
         } else {
             $category->create($request->nombre, $request->descripcion);
             newFlashMessage('test', 'Categoria ' . ucwords($request->nombre) . " creada.");
             return redirect('admin/category/');
         }
     } elseif (isset($id)) {
         $categories = new Categories();
         $category = $categories->find($id);
         return view('admin/categories/update', compact('category'), 'baseAdmin');
     } else {
         return view('admin/categories/create', '', 'baseAdmin');
     }
 }
开发者ID:GadgetsLab,项目名称:Metaherrera,代码行数:22,代码来源:AdminController.php


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