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


PHP Category::create方法代码示例

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


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

示例1: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['name' => 'required', 'description' => 'required', 'parent_id' => 'required']);
     $Category = Category::create($request->all());
     Session::flash('flash_message', 'Category added!');
     return redirect("backoffice/categories/{$Category->parent_id}");
 }
开发者ID:AntonBeletsky,项目名称:laravel_minishop,代码行数:12,代码来源:CategoriesController.php

示例2: testAccessoryCategoryAdd

 public function testAccessoryCategoryAdd()
 {
     $category = factory(Category::class, 'accessory-category')->make();
     $values = ['name' => $category->name, 'category_type' => $category->category_type];
     Category::create($values);
     $this->tester->seeRecord('categories', $values);
 }
开发者ID:dmeltzer,项目名称:snipe-it,代码行数:7,代码来源:CategoryTest.php

示例3: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(CreateCategoryRequest $request)
 {
     $category = new Category();
     $data = $request->input();
     $category->create($data);
     return Redirect()->route('categories');
 }
开发者ID:RsanabriaZ,项目名称:web-catalog,代码行数:13,代码来源:CategoryController.php

示例4: store

 public function store(StoreCategoryRequest $request)
 {
     $input = $request->all();
     $input['slug'] = str_replace(' ', '_', strtolower($input['name']));
     $category = Category::create($input);
     return $this->createResponse($category);
 }
开发者ID:restoko,项目名称:restoko-api,代码行数:7,代码来源:CategoriesController.php

示例5: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Category::create(['name' => '推荐', 'slug' => 'recommend']);
     Category::create(['name' => '其他', 'slug' => 'other']);
     //        $categories = factory(Category::class)->times(10)->make();
     //        Category::insert($categories->toArray());
 }
开发者ID:axex,项目名称:kratos,代码行数:12,代码来源:CategoryTableSeeder.php

示例6: postCategories

 public function postCategories(Request $request)
 {
     if ($request->has('adds')) {
         $adds = $request->adds;
         for ($i = 0; $i < count($adds); $i++) {
             if ($adds[$i]['parent_id'] == 'null') {
                 Category::create(['title' => $adds[$i]['title']]);
             } else {
                 $parent = Category::find($adds[$i]['parent_id']);
                 $child = $parent->children()->create(['title' => $adds[$i]['title'], 'slug' => str_slug($adds[$i]['title'])]);
                 for ($j = 0; $j < count($adds); $j++) {
                     if ($adds[$j]['parent_id'] == $adds[$i]['id']) {
                         $adds[$j]['parent_id'] = $child->id;
                     }
                 }
             }
         }
     }
     if ($request->has('updates')) {
         $updates = $request->updates;
         for ($i = 0; $i < count($updates); $i++) {
             $category = Category::find($updates[$i]['id']);
             $category->update(['title' => $updates[$i]['title'], 'slug' => str_slug($updates[$i]['title'])]);
         }
     }
     if ($request->has('deletes')) {
         $deletes = $request->deletes;
         for ($i = 0; $i < count($deletes); $i++) {
             Category::destroy($deletes[$i]);
         }
     }
 }
开发者ID:ninjamonz,项目名称:laravel_catalog_example,代码行数:32,代码来源:CategoriesController.php

示例7: store

 /**
  * Store a newly created Category in storage.
  *
  * @param CreateCategoryRequest $request
  *
  * @return Response
  */
 public function store(CreateCategoryRequest $request)
 {
     $input = $request->all();
     $category = Category::create($input);
     Flash::message('Category saved successfully.');
     return redirect(route('admin.categories.index'));
 }
开发者ID:jclyons52,项目名称:mycourse-rocks,代码行数:14,代码来源:AdminCategoryController.php

示例8: store

 /**
  * do add data
  * @param mixed $request
  * @return redirect
  */
 public function store(Request $request)
 {
     $messages = ['cate_name.required' => 'Category name is necessary!'];
     $this->validate($request, ['cate_name' => 'required'], $messages);
     Category::create($request->all());
     return redirect(route('admin.category.index'))->with('info', 'Added Successfully~~');
 }
开发者ID:Jokeramc,项目名称:amc,代码行数:12,代码来源:CategoryController.php

示例9: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // App\Models\Category::create([
     //     'title'=>'Fuel',
     //     'slug'=>'fuel',
     //     'description'=>'Enter amounts of petrol',
     //     'estimate'=>20.00,
     //     'income'=>0,
     //     'colour'=>'#00FF00'
     // ]);
     //
     // App\Models\Category::create([
     //     'title'=>'Fixed',
     //     'slug'=>'fixed',
     //     'description'=>'Fixed that goes in every month',
     //     'estimate'=>0,
     //     'income'=>0,
     //     'colour'=>'#FF6600'
     // ]);
     $faker = Faker::create();
     foreach (range(1, 12) as $i) {
         $word = $faker->word;
         \App\Models\Category::create(['title' => $word, 'slug' => $word, 'description' => $faker->sentence(8), 'estimate' => number_format($faker->randomFloat(2, 0, 999), 2), 'income' => 0, 'colour' => $faker->hexcolor]);
     }
 }
开发者ID:nq2916,项目名称:savings,代码行数:30,代码来源:CategoriesTableSeeder.php

示例10: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('categories')->truncate();
     $categories = [['name' => 'Appetizers', 'slug' => 'appetizers', 'description' => 'sandwitches'], ['name' => 'Chefs Recommendations', 'slug' => 'chiefs-recommendations', 'description' => 'sandwitches'], ['name' => 'Student Meals', 'slug' => 'student-meals', 'description' => 'sandwitches'], ['name' => 'Pizzas and Salads', 'slug' => 'pizzas-salads', 'description' => 'sandwitches'], ['name' => 'Non-coffee based drinks', 'slug' => 'non-coffee-based-drinks', 'description' => 'inumin'], ['name' => 'Javalogy Classics', 'slug' => 'javalogy-classics', 'description' => 'sandwitches'], ['name' => 'Javalogy Specialties', 'slug' => 'javalogy-specialties', 'description' => 'sandwitches'], ['name' => 'Frost', 'slug' => 'frost', 'description' => 'sandwitches'], ['name' => 'Over-Iced', 'slug' => 'over-iced', 'description' => 'sandwitches'], ['name' => 'Signature Drinks', 'slug' => 'signature-drinks', 'description' => 'sandwitches'], ['name' => 'Alcoholic Coffee Beverages', 'slug' => 'javalogy-classics', 'description' => 'sandwitches'], ['name' => 'Shooters', 'slug' => 'shooters', 'description' => 'shooters'], ['name' => 'Cocktails', 'slug' => 'cocktails', 'description' => 'cocktails'], ['name' => 'Beers', 'slug' => 'beers', 'description' => 'beers'], ['name' => 'Specialty', 'slug' => 'specialty', 'description' => 'specialty'], ['name' => 'On The Rocks', 'slug' => 'on-the-rocks', 'description' => 'on the rocks'], ['name' => 'Tequilla Shots', 'slug' => 'tequilla-shots', 'description' => 'tequilla shots'], ['name' => 'Cogna Shots', 'slug' => 'cogna-shots', 'description' => 'cogna-shots'], ['name' => 'Per Bottle', 'slug' => 'per-bottle', 'description' => 'per bottle'], ['name' => 'Gourmet, Burgers, Paninis and Quesadillas', 'slug' => 'gourmet-burgers-paninis-quesadillas', 'description' => 'sandwitches'], ['name' => 'Rice Extras', 'slug' => 'rice-extras', 'description' => 'sandwitches'], ['name' => 'Pasta', 'slug' => 'pasta', 'description' => 'sandwitches'], ['name' => 'Desserts', 'slug' => 'desserts', 'description' => 'sandwitches']];
     foreach ($categories as $category) {
         \App\Models\Category::create($category);
     }
 }
开发者ID:restoko,项目名称:restoko-api,代码行数:13,代码来源:CategoryTableSeeder.php

示例11: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Category::create(['id' => 0, 'name' => "All Wares"]);
     $category_names = array("Furniture", "Home Appliances", "Vehicles", "Study Materials", "Books");
     foreach ($category_names as $category) {
         Category::create(['name' => $category]);
     }
 }
开发者ID:shwetasabne,项目名称:StudentBarter,代码行数:13,代码来源:CategoryTableSeeder.php

示例12: handle

 /**
  * Handle the command.
  *
  * @param  CreateCategoryCommand  $command
  * @return void
  */
 public function handle(CreateCategoryCommand $command)
 {
     $category = Category::create(['title' => $command->title, 'slug' => $command->slug, 'description' => $command->description, 'estimate' => $command->estimate, 'income' => $command->income, 'colour' => $command->colour]);
     if (!empty($category)) {
         return $category;
     }
     return false;
 }
开发者ID:nq2916,项目名称:savings,代码行数:14,代码来源:CreateCategoryCommandHandler.php

示例13: run

 public function run()
 {
     DB::table('categories')->delete();
     for ($i = 0; $i < 276; $i++) {
         $faker = Faker\Factory::create();
         Category::create(['name' => $faker->sentence]);
     }
 }
开发者ID:ronal2do,项目名称:dave_brubeck,代码行数:8,代码来源:DatabaseSeeder.php

示例14: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Requests\Backend\StoreCategoryRequest $request
  * @return \Illuminate\Http\Response
  */
 public function store(Requests\Backend\StoreCategoryRequest $request)
 {
     $this->authorize($category = new Category());
     $data = $request->all();
     $data['type'] = Category::TYPE_ARTICLE;
     $category->create($data);
     return redirect()->action('Backend\\CategoryController@show', [$category]);
 }
开发者ID:niefufeng,项目名称:drip,代码行数:14,代码来源:CategoryController.php

示例15: run

 public function run()
 {
     Category::create(['title' => 'Frontend (Web)', 'children' => [['title' => 'Maps', 'image' => 'maps.png'], ['title' => 'CSS3', 'image' => 'css3.png'], ['title' => 'UI Elements', 'image' => 'ui.png'], ['title' => 'Icons'], ['title' => 'Social', 'image' => 'social.png'], ['title' => 'Scrolling'], ['title' => 'Lazy Loading'], ['title' => 'Charts', 'image' => 'charts.png'], ['title' => 'Angular', 'image' => 'angular.png'], ['title' => 'Bootstrap', 'image' => 'bootpstrap.png'], ['title' => 'jQuery', 'image' => 'jquery.png'], ['title' => 'Resources', 'image' => 'resources.png']]]);
     Category::create(['title' => 'PHP', 'children' => [['title' => 'Laravel', 'image' => 'laravel.png'], ['title' => 'Wordpress', 'image' => 'wordpress.png'], ['title' => 'APIs', 'image' => 'api.png'], ['title' => 'Packages', 'image' => 'packages.png']]]);
     Category::create(['title' => 'Design', 'children' => [['title' => 'Type'], ['title' => 'Drawing'], ['title' => 'Resources'], ['title' => 'Mockups'], ['title' => 'App Icons'], ['title' => 'Lettering'], ['title' => 'Inspirtation'], ['title' => 'UX']]]);
     Category::create(['title' => 'Game Development', 'children' => [['title' => 'IOS'], ['title' => 'Android']]]);
     Category::create(['title' => 'This n That']);
 }
开发者ID:elieandraos,项目名称:project-evey,代码行数:8,代码来源:CategoriesTableSeeder.php


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