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


PHP Category::create方法代码示例

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


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

示例1: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $input = Input::all();
     $validation = Validator::make($input, Category::$rules);
     if ($validation->passes()) {
         $this->category->create($input);
         return Redirect::to('admin?section=categories')->with(array('note' => Lang::get('lang.new_category_success'), 'note_type' => 'success'));
     }
     return Redirect::to('admin?section=categories')->withInput()->withErrors($validation)->with('message', 'There were validation errors.');
 }
开发者ID:giangcoffee,项目名称:ninja,代码行数:15,代码来源:CategoriesController.php

示例2: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $val = $this->categoryRepository->getCreateForm();
     if (!$val->isValid()) {
         return Redirect::back()->withInput()->withErrors($val->getErrors());
     }
     if (!($record = $this->categoryRepository->create($val->getInputData()))) {
         return Redirect::back()->with('errors', $this->categoryRepository->errors())->withInput();
     }
     return Redirect::action('AdminCategoriesController@index')->with('success', 'Category Created');
 }
开发者ID:christiannwamba,项目名称:laravel-site,代码行数:16,代码来源:AdminCategoriesController.php

示例3: createHandle

 public function createHandle()
 {
     $path = DirectoryHelpers::seoString(e(Input::get('path')));
     $nice_input_names = ['is_root' => trans('directory.is_root'), 'name' => trans('directory.name'), 'path' => trans('directory.path'), 'description' => trans('directory.description'), 'keywords' => trans('directory.keywords')];
     $rules = ['is_root' => 'required', 'name' => 'required|between:2,50|unique:categories', 'path' => 'required|between:2,50|unique:categories', 'description' => 'between:5,1000', 'keywords' => 'between:5,255'];
     $is_root = Input::get('is_root');
     if ('no' == $is_root) {
         $nice_input_names['parent_id'] = trans('directory.parent');
         $rules['parent_id'] = 'not_in:0';
     }
     $validator = Validator::make(Input::all(), $rules, [], $nice_input_names);
     if ($validator->fails()) {
         return Redirect::route('category.create')->withErrors($validator)->withInput();
     }
     try {
         if ('yes' == $is_root) {
             $status = Acl::isSuperAdmin() ? 1 : 0;
             $node = Category::create(['status' => $status, 'name' => e(Input::get('name')), 'slug' => $path, 'path' => $path, 'description' => e(Input::get('description')), 'keywords' => e(Input::get('keywords'))])->makeRoot();
         }
         if ('no' == $is_root) {
             $parent = Category::find(e(Input::get('parent_id')));
             $node = Category::create(['status' => $status, 'name' => e(Input::get('name')), 'slug' => $path, 'path' => $path, 'description' => e(Input::get('description')), 'keywords' => e(Input::get('keywords'))])->makeChildOf($parent);
         }
         Acl::addAdmin($node);
         return Redirect::route('category.create')->with('success', Lang::get('directory.category_added', ['name' => Input::get('name')]));
     } catch (Exception $ex) {
         return Redirect::route('category.create')->withErrors($ex->getMessage())->withInput();
     }
 }
开发者ID:CalinB,项目名称:web-directory,代码行数:29,代码来源:CategoriesController.php

示例4: run

 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Category::create([]);
     }
 }
开发者ID:uknowcreation,项目名称:laravelblog,代码行数:7,代码来源:CategoriesTableSeeder.php

示例5: run

 public function run()
 {
     DB::table('categorys')->delete();
     Category::create(array('name' => 'Feeling'));
     Category::create(array('name' => 'Phycial'));
     Category::create(array('name' => 'Logical'));
 }
开发者ID:phyowailinn,项目名称:lara-vel,代码行数:7,代码来源:CategoryTableSeeder.php

示例6: run

 public function run()
 {
     Category::create(array('name' => 'Movies'));
     Category::create(array('name' => 'Books'));
     Category::create(array('name' => 'Music'));
     Category::create(array('name' => 'Episodes'));
 }
开发者ID:ne0lite,项目名称:Tracker,代码行数:7,代码来源:DatabaseSeeder.php

示例7: run

 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Category::create(['name' => $faker->word, 'subscription_price' => $faker->sentence, 'test_price' => $faker->randomNumber, 'words' => $faker->randomNumber]);
     }
 }
开发者ID:SenhorBardell,项目名称:wordotheday,代码行数:7,代码来源:CategoriesTableSeeder.php

示例8: run

 public function run()
 {
     DB::table('categories')->delete();
     Category::create(array('id' => 1, 'name' => 'Web Development'));
     Category::create(array('id' => 2, 'name' => 'Web Design'));
     Category::create(array('id' => 3, 'name' => 'Testing'));
 }
开发者ID:shruti222patel,项目名称:laravel-model-demo,代码行数:7,代码来源:CategorySeeder.php

示例9: create

 function create($parent_id = FALSE)
 {
     //load block submit helper and append in the head
     $this->template->append_metadata(block_submit_button());
     //get the parent id
     $parent_id = $this->uri->segment(4) ? $this->uri->segment(4) : $this->input->post('parent_id', TRUE);
     //Filter & Sanitize $id
     $parent_id = $parent_id != 0 ? filter_var($parent_id, FILTER_VALIDATE_INT) : NULL;
     //Rules for validation
     $this->_set_rules();
     //create control variables
     $this->template->set('title', lang('web_category_create'));
     $this->template->set('updType', 'create');
     $this->template->set('parent_id', $parent_id);
     //validate the fields of form
     if ($this->form_validation->run() == FALSE) {
         //load the view and the layout
         $this->template->build('categories/create');
     } else {
         // build array for the model
         $form_data = array('name' => set_value('name'), 'category_id' => $parent_id);
         $category = Category::create($form_data);
         // run insert model to write data to db
         if ($category->is_valid()) {
             $this->session->set_flashdata('message', array('type' => 'success', 'text' => lang('web_create_success')));
             redirect('admin/categories/' . $parent_id);
         }
         if ($category->is_invalid()) {
             //$this->session->set_flashdata('message', array( 'type' =>  'error', 'text' => lang('web_create_failed') ));
             $this->session->set_flashdata('message', array('type' => 'error', 'text' => $category->errors->full_messages()));
             redirect('admin/categories/' . $parent_id);
         }
     }
 }
开发者ID:csiber,项目名称:CodeIgniter-Starter,代码行数:34,代码来源:categories.php

示例10: run

 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 3) as $index) {
         Category::create(['name' => $faker->sentence(1), 'href' => '#']);
     }
 }
开发者ID:syafdia,项目名称:PAS,代码行数:7,代码来源:CategoriesTableSeeder.php

示例11: addGarmentCategory

 public function addGarmentCategory()
 {
     $garms = Category::get();
     $isAdded = FALSE;
     $validInput = TRUE;
     $regex = "/^[a-zA-Z\\'\\-]+( [a-zA-Z\\'\\-]+)*\$/";
     $regexDesc = "/^[a-zA-Z0-9\\'\\-\\.\\,]+( [a-zA-Z0-9\\,\\'\\-\\.]+)*\$/";
     if (!trim(Input::get('addGarmentName')) == '' || !trim(Input::get('addGarmentDesc')) == '') {
         $validInput = TRUE;
         if (preg_match($regex, Input::get('addGarmentName')) && preg_match($regexDesc, Input::get('addGarmentDesc'))) {
             $validInput = TRUE;
         } else {
             $validInput = FALSE;
         }
     } else {
         $validInput = FALSE;
     }
     foreach ($garms as $garm) {
         if (strcasecmp($garm->strGarmentCategoryName, trim(Input::get('addGarmentName'))) == 0) {
             $isAdded = TRUE;
         }
     }
     if ($validInput) {
         if (!$isAdded) {
             $garment = Category::create(array('strGarmentCategoryID' => Input::get('addGarmentID'), 'strGarmentCategoryName' => trim(Input::get('addGarmentName')), 'strGarmentCategoryDesc' => trim(Input::get('addGarmentDesc')), 'boolIsActive' => 1));
             $garment->save();
             return Redirect::to('/maintenance/garments?success=true');
         } else {
             return Redirect::to('/maintenance/garments?success=duplicate');
         }
     } else {
         return Redirect::to('/maintenance/garments?input=invalid');
     }
 }
开发者ID:MorrielAlexis,项目名称:SADTAILORING,代码行数:34,代码来源:GarmentCategoryController.php

示例12: store

 /**
  * Store a newly created category in storage.
  *
  * @return Response
  */
 public function store()
 {
     $categoryValidator = Validator::make($data = Input::all(), Category::$rules);
     if ($categoryValidator->fails()) {
         return Redirect::back()->withErrors($categoryValidator)->withInput();
     }
     /* Category */
     if (Input::has('createCategory')) {
         Category::create($data);
         $message = "登録しました。";
     }
     if (Input::has('deleteCategory')) {
         $c = Category::where('Bumon', Input::get('Bumon'))->first();
         Category::destroy($c->id);
         $message = "削除しました。";
         if (Input::has('selectedCategory')) {
             Input::replace(array('selectedCategory', ''));
         }
     }
     if (Input::has('updateCategory')) {
         $err = array('required' => '新しい部門名を入力してください。');
         $categoryValidator = Validator::make($data = Input::all(), Category::$update_rules, $err);
         if ($categoryValidator->fails()) {
             return Redirect::back()->withErrors($categoryValidator)->withInput();
         }
         $c = Category::where('Bumon', Input::get('Bumon'))->first();
         Category::destroy($c->id);
         $data['Bumon'] = $data['new_categoryName'];
         Category::create($data);
         $message = "更新しました。";
     }
     return Redirect::route('employees.index')->with('message', $message);
 }
开发者ID:noikiy,项目名称:posco-laravel-server,代码行数:38,代码来源:CategoriesController.php

示例13: seedCategory

 /**
  * 填充分类数据
  * @return void
  */
 private function seedCategory()
 {
     foreach (array('PHP-PSR 代码标准', '新分类二', '新分类三', '新分类四', '新分类五') as $key => $value) {
         Category::create(array('name' => $value, 'sort_order' => $key + 1));
     }
     $this->command->info('测试分类数据填充完毕');
 }
开发者ID:ningcaichen,项目名称:laravel-4.1-simple-blog,代码行数:11,代码来源:BlogTablesSeeder.php

示例14: run

 public function run()
 {
     DB::table('users')->delete();
     Category::create(['name' => 'Electronics']);
     Category::create(['name' => 'Sports']);
     Category::create(['name' => 'Furnitures']);
 }
开发者ID:CyborgSamrat,项目名称:shomogro4,代码行数:7,代码来源:DatabaseSeeder.php

示例15: run

 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Category::create(['title' => $faker->sentence()]);
     }
 }
开发者ID:rizqon,项目名称:ta,代码行数:7,代码来源:CategoriesTableSeeder.php


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