當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Category::create方法代碼示例

本文整理匯總了PHP中app\Category::create方法的典型用法代碼示例。如果您正苦於以下問題:PHP Category::create方法的具體用法?PHP Category::create怎麽用?PHP Category::create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\Category的用法示例。


在下文中一共展示了Category::create方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     if ($Category = $this->Category->create($request->all())) {
         Flash::success(trans('app.Successful operation'));
         return redirect()->route('dashboard.category.index', ['typeId' => $Category->type_id]);
     } else {
         Flash::error(trans('app.Operation failed'));
         return redirect()->back()->withInput($request->all());
     }
 }
開發者ID:jvlstudio,項目名稱:3N1WebSite,代碼行數:15,代碼來源:CategoryController.php

示例2: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(CategoryFormRequest $request)
 {
     // Save new category
     Category::create($request->all());
     flash()->success('New category has been added!');
     return redirect('categories');
 }
開發者ID:kakapa,項目名稱:erpbox,代碼行數:13,代碼來源:CategoriesController.php

示例3: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker\Factory::create('it_IT');
     Category::create(['name' => 'News', 'slug' => 'news', 'description' => $faker->paragraph(3)]);
     Category::create(['name' => 'Interviste', 'slug' => 'interviste', 'description' => $faker->paragraph(3)]);
     Category::create(['name' => 'Reportage', 'slug' => 'reportage', 'description' => $faker->paragraph(3)]);
 }
開發者ID:reverserob,項目名稱:Blog_Laravel,代碼行數:12,代碼來源:CategoryTableSeeder.php

示例4: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['title' => 'required|string|max:255|unique:categories', 'parent_id' => 'exists:categories,id']);
     Category::create($request->all());
     \Flash::success('Category saved.');
     return redirect()->route('categories.index');
 }
開發者ID:rawaludin,項目名稱:approcket-preproject,代碼行數:13,代碼來源:CategoriesController.php

示例5: run

 public function run()
 {
     DB::table('categories')->truncate();
     \App\Category::create(['name' => 'Tips & Tutorials', 'slug' => 'tips-tutorials']);
     \App\Category::create(['name' => 'Packages', 'slug' => 'packages']);
     \App\Category::create(['name' => 'Applications', 'slug' => 'apps']);
 }
開發者ID:laravelnews,項目名稱:links,代碼行數:7,代碼來源:CategoryTableSeeder.php

示例6: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(StoreCategoryRequest $request)
 {
     //
     Category::create($request->all());
     $status = 'New category added.';
     return \Redirect::route('categories.index')->with(['status' => $status]);
 }
開發者ID:matthiku,項目名稱:LaravelWithSocialite,代碼行數:13,代碼來源:CategoryController.php

示例7: store

 public function store(CategoryRequest $request)
 {
     $input = $request->all();
     $category = Category::create($input);
     session()->flash('flash_message', 'You have been addded 1 category!');
     return redirect()->route('settings.category');
 }
開發者ID:arooth,項目名稱:Library-Management-System,代碼行數:7,代碼來源:CategoryController.php

示例8: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('tbl_categories')->truncate();
     \App\Category::create(['category' => 'Clothes']);
     \App\Category::create(['category' => 'Miscellaneous']);
     \App\Category::create(['category' => 'Music']);
 }
開發者ID:justmemaarten,項目名稱:vlambeer,代碼行數:12,代碼來源:CategoryTableSeeder.php

示例9: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('locations')->truncate();
     Location::create(['name' => 'Phase 1, Level 1']);
     Location::create(['name' => 'Phase 1, Level 2']);
     Location::create(['name' => 'Phase 1, Level 3']);
     Location::create(['name' => 'Phase 2, Level 1']);
     Location::create(['name' => 'Phase 2, Level 2']);
     Location::create(['name' => 'Phase 2, Level 3']);
     Location::create(['name' => 'Phase 3, Level 1']);
     Location::create(['name' => 'Phase 3, Level 2']);
     Location::create(['name' => 'Phase 3, Level 3']);
     DB::table('areas')->truncate();
     Area::create(['name' => 'AME']);
     Area::create(['name' => 'M&W']);
     Area::create(['name' => 'Ramp']);
     Area::create(['name' => 'SCI']);
     Area::create(['name' => 'Tool Install']);
     DB::table('categories')->truncate();
     Category::create(['name' => 'Spec Gas']);
     Category::create(['name' => 'Electrical']);
     Category::create(['name' => 'Base Build']);
     Category::create(['name' => 'Design Request']);
     Category::create(['name' => 'Layout Optimization']);
     Category::create(['name' => 'Safety']);
     DB::table('status')->truncate();
     Status::create(['name' => 'New', 'slug' => 'new']);
     Status::create(['name' => 'Open/Needs Further Review', 'slug' => 'open-needs-further-review']);
     Status::create(['name' => 'Waiting for Approval', 'slug' => 'waiting-for-approval']);
     Status::create(['name' => 'Rejected', 'slug' => 'rejected']);
     Status::create(['name' => 'Approved', 'slug' => 'approved']);
 }
開發者ID:gfdeveloper,項目名稱:LCCB,代碼行數:37,代碼來源:RandomTableSeeder.php

示例10: run

 public function run()
 {
     DB::table('categories')->delete();
     Category::create(array('id' => 3, 'created_at' => '2015-11-09 16:10:46', 'updated_at' => '2015-11-09 16:10:46', 'name' => 'Fruits'));
     Category::create(array('id' => 4, 'created_at' => '2015-11-09 16:11:39', 'updated_at' => '2015-11-09 16:11:39', 'name' => 'Vegetables'));
     Category::create(array('id' => 5, 'created_at' => '2015-11-09 16:13:46', 'updated_at' => '2015-11-09 16:13:46', 'name' => 'Grains'));
 }
開發者ID:edgars-supe,項目名稱:wt2-hw2,代碼行數:7,代碼來源:DatabaseSeeder.php

示例11: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['name' => 'required|unique:categories|max:255', 'color' => 'required']);
     $category = Category::create(['name' => $request->get('name'), 'slug' => str_slug($request->get('name')), 'description' => $request->get('description'), 'color' => $request->get('color')]);
     $message = $category ? 'Categoria agregada correctamente!' : 'La categoria NO pudo agregarse!';
     return redirect()->route('admin.category.index')->with('message', $message);
 }
開發者ID:kazamax,項目名稱:tienda,代碼行數:13,代碼來源:CategoryController.php

示例12: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, $this->rules);
     $input = Input::all();
     Category::create($input);
     return Redirect::route('categories.index')->with('message', 'New category created!');
 }
開發者ID:lamwin,項目名稱:laravel-blog,代碼行數:12,代碼來源:CategoriesController.php

示例13: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker\Factory::create();
     foreach (range(1, 10) as $index) {
         Category::create(['title' => $faker->sentence, 'description' => $faker->paragraph(1), 'parent_id' => NULL, 'created_by' => 1, 'updated_by' => 1, 'ordering' => 1, 'status' => true]);
     }
 }
開發者ID:TEACHER-KEAK,項目名稱:GAD,代碼行數:12,代碼來源:CategoryTableSeeder.php

示例14: run

 public function run()
 {
     DB::table('categories')->delete();
     Category::create(array('name' => 'Category 1'));
     Category::create(array('name' => 'Category 2'));
     Category::create(array('name' => 'Category 3'));
 }
開發者ID:starmatt,項目名稱:webpapa,代碼行數:7,代碼來源:CategoriesTableSeeder.php

示例15: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(CategoryRequest $request)
 {
     Category::create($request->all());
     flash()->success('Your category has been created!');
     \Cache::tags('categories')->flush();
     return redirect('admin/categories/index');
 }
開發者ID:kpaxer,項目名稱:laravel-blog,代碼行數:12,代碼來源:CategoriesController.php


注:本文中的app\Category::create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。