Пример #1
0
 /**
  * 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.');
 }
 /**
  * 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');
 }
Пример #3
0
 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();
     }
 }
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Category::create([]);
     }
 }
Пример #5
0
 public function run()
 {
     DB::table('categorys')->delete();
     Category::create(array('name' => 'Feeling'));
     Category::create(array('name' => 'Phycial'));
     Category::create(array('name' => 'Logical'));
 }
Пример #6
0
 public function run()
 {
     Category::create(array('name' => 'Movies'));
     Category::create(array('name' => 'Books'));
     Category::create(array('name' => 'Music'));
     Category::create(array('name' => 'Episodes'));
 }
 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]);
     }
 }
 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'));
 }
Пример #9
0
 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);
         }
     }
 }
Пример #10
0
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 3) as $index) {
         Category::create(['name' => $faker->sentence(1), 'href' => '#']);
     }
 }
 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');
     }
 }
 /**
  * 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);
 }
 /**
  * 填充分类数据
  * @return void
  */
 private function seedCategory()
 {
     foreach (array('PHP-PSR 代码标准', '新分类二', '新分类三', '新分类四', '新分类五') as $key => $value) {
         Category::create(array('name' => $value, 'sort_order' => $key + 1));
     }
     $this->command->info('测试分类数据填充完毕');
 }
Пример #14
0
 public function run()
 {
     DB::table('users')->delete();
     Category::create(['name' => 'Electronics']);
     Category::create(['name' => 'Sports']);
     Category::create(['name' => 'Furnitures']);
 }
Пример #15
0
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Category::create(['title' => $faker->sentence()]);
     }
 }
Пример #16
0
 public static function create($data)
 {
     session_start();
     $headers = apache_request_headers();
     $token = $headers['X-Auth-Token'];
     if (!$headers['X-Auth-Token']) {
         header('Invalid CSRF Token', true, 401);
         return print json_encode(array('success' => false, 'status' => 400, 'msg' => 'Invalid CSRF Token / Bad Request / Unauthorized ... Please Login again'), JSON_PRETTY_PRINT);
     } else {
         if ($token != $_SESSION['form_token']) {
             header('Invalid CSRF Token', true, 401);
             return print json_encode(array('success' => false, 'status' => 400, 'msg' => 'Invalid CSRF Token / Bad Request / Unauthorized ... Please Login again'), JSON_PRETTY_PRINT);
         } else {
             if (!isset($data['category_name']) && empty($data['category_name'])) {
                 return print json_encode(array('success' => false, 'status' => 200, 'msg' => 'Category Name is required'), JSON_PRETTY_PRINT);
                 die;
             } else {
                 if (!isset($data['time']) && empty($data['time'])) {
                     return print json_encode(array('success' => false, 'status' => 200, 'msg' => 'Time Limit for Quiz is required'), JSON_PRETTY_PRINT);
                     die;
                 } else {
                     $var = ["category_name" => $data['category_name'], "time" => $data['time']];
                     Category::create($var);
                 }
             }
         }
     }
 }
Пример #17
0
 public function nestUptoAt($node, $levels = 10, $attrs = array())
 {
     for ($i = 0; $i < $levels; $i++, $node = $new) {
         $new = Category::create(array_merge($attrs, array('name' => "{$node->name}.1")));
         $new->makeChildOf($node);
     }
 }
Пример #18
0
 public function run()
 {
     DB::table('categorys')->delete();
     Category::create(array('code' => 'FOOD_AREA', 'parent_code' => 'FOOD', 'level' => 1, 'name' => '原产地'));
     Category::create(array('code' => 'FOOD_CATEGORY', 'parent_code' => 'FOOD', 'level' => 1, 'name' => '食材分类'));
     /*** 菜系 ***/
     Category::create(array('code' => 'COOKBOOK_STYLE', 'parent_code' => 'COOKBOOK', 'level' => 1, 'name' => '菜系'));
     Category::create(array('code' => 'MIN_CAI', 'parent_code' => 'COOKBOOK_STYLE', 'level' => 2, 'name' => '闽菜'));
     Category::create(array('code' => 'YUE_CAI', 'parent_code' => 'COOKBOOK_STYLE', 'level' => 2, 'name' => '粤菜'));
     Category::create(array('code' => 'XIANG_CAI', 'parent_code' => 'COOKBOOK_STYLE', 'level' => 2, 'name' => '湘菜'));
     /*** 人群/场景 ***/
     Category::create(array('code' => 'COOKBOOK_CROWD', 'parent_code' => 'COOKBOOK', 'level' => 1, 'name' => '人群/场景'));
     Category::create(array('code' => 'ZCSP', 'parent_code' => 'COOKBOOK_CROWD', 'level' => 2, 'name' => '早餐食谱'));
     Category::create(array('code' => 'YFSP', 'parent_code' => 'COOKBOOK_CROWD', 'level' => 2, 'name' => '孕妇食谱'));
     Category::create(array('code' => 'CFSP', 'parent_code' => 'COOKBOOK_CROWD', 'level' => 2, 'name' => '产妇食谱'));
     /*** 菜式 ***/
     Category::create(array('code' => 'COOKBOOK_THEME', 'parent_code' => 'COOKBOOK', 'level' => 1, 'name' => '菜式'));
     Category::create(array('code' => 'JIA_CHANG', 'parent_code' => 'COOKBOOK_THEME', 'level' => 2, 'name' => '家常菜'));
     Category::create(array('code' => 'XIA_FAN', 'parent_code' => 'COOKBOOK_THEME', 'level' => 2, 'name' => '下饭菜'));
     Category::create(array('code' => 'TIAN_PIN', 'parent_code' => 'COOKBOOK_THEME', 'level' => 2, 'name' => '甜品'));
     Category::create(array('code' => 'ROU_LEI', 'parent_code' => 'COOKBOOK_THEME', 'level' => 2, 'name' => '家常菜'));
     /*** 烹饪方法 ***/
     Category::create(array('code' => 'COOKBOOK_METHOD', 'parent_code' => 'COOKBOOK', 'level' => 1, 'name' => '烹饪方法'));
     Category::create(array('code' => 'JIAN', 'parent_code' => 'COOKBOOK_METHOD', 'level' => 2, 'name' => '煎'));
     Category::create(array('code' => 'CHAO', 'parent_code' => 'COOKBOOK_METHOD', 'level' => 2, 'name' => '炒'));
     Category::create(array('code' => 'ZHA', 'parent_code' => 'COOKBOOK_METHOD', 'level' => 2, 'name' => '炸'));
     /*** 商品分类 ***/
     Category::create(array('code' => 'PRODUCT_CATEGORY_XXSP', 'parent_code' => 'PRODUCT_CATEGORY', 'level' => 2, 'name' => '休闲食品'));
     /*** 图文分类 ***/
     Category::create(array('code' => 'ARTICLE_CATEGORY', 'parent_code' => 'ARTICLE', 'level' => 1, 'name' => '图文分类'));
     Category::create(array('code' => 'ARTICLE_CATEGORY_OTHER', 'parent_code' => 'ARTICLE_CATEGORY', 'level' => 2, 'name' => '其他'));
 }
Пример #19
0
 public function run()
 {
     DB::table('categories')->delete();
     Category::create(['name' => 'Konpa', 'slug' => 'konpa']);
     Category::create(['name' => 'Rasin', 'slug' => 'rasin']);
     Category::create(['name' => 'Reggae', 'slug' => 'reggae']);
     Category::create(['name' => 'Yanvalou', 'slug' => 'yanvalou']);
     Category::create(['name' => 'R&B', 'slug' => 'rb']);
     Category::create(['name' => 'Rap Kreyòl', 'slug' => 'rap-kreyol']);
     Category::create(['name' => 'Dancehall', 'slug' => 'dancehall']);
     Category::create(['name' => 'Lòt Jan', 'slug' => 'Lot-jan']);
     Category::create(['name' => 'Kanaval', 'slug' => 'kanaval']);
     Category::create(['name' => 'Gospèl', 'slug' => 'gospel']);
     Category::create(['name' => 'Levanjil', 'slug' => 'levanjil']);
     Category::create(['name' => 'DJ', 'slug' => 'dj']);
     Category::create(['name' => 'Rabòday', 'slug' => 'raboday']);
     Category::create(['name' => 'Rara', 'slug' => 'rara']);
     Category::create(['name' => 'Reggaeton', 'slug' => 'reggaeton']);
     Category::create(['name' => 'House', 'slug' => 'house']);
     Category::create(['name' => 'Jazz', 'slug' => 'jazz']);
     Category::create(['name' => 'Raga', 'slug' => 'raga']);
     Category::create(['name' => 'Soul', 'slug' => 'soul']);
     Category::create(['name' => 'Sanba', 'slug' => 'sanba']);
     Category::create(['name' => 'Rock & Roll', 'slug' => 'rock-roll']);
     Category::create(['name' => 'Techno', 'slug' => 'techno']);
     Category::create(['name' => 'Slow', 'slug' => 'slow']);
     Category::create(['name' => 'Salsa', 'slug' => 'salsa']);
     Category::create(['name' => 'Twoubadou', 'slug' => 'twoubadou']);
     Category::create(['name' => 'Riddim', 'slug' => 'riddim']);
     Category::create(['name' => 'Afro', 'slug' => 'afro']);
     Category::create(['name' => 'Slam', 'slug' => 'slam']);
 }
Пример #20
0
 public function run()
 {
     DB::table('categories')->delete();
     Category::create(['name' => 'Sales & Marketing', 'description' => 'Lorem ipsum dolor sit amet, omittam platonem quodsi']);
     Category::create(['name' => 'Customer Support', 'description' => 'Lorem ipsum dolor sit amet, omittam platonem quodsi']);
     Category::create(['name' => 'Community', 'description' => 'Lorem ipsum dolor sit amet, omittam platonem quodsi']);
 }
 public function run()
 {
     $faker = $this->getFaker();
     for ($i = 0; $i < 10; $i++) {
         $name = ucwords($faker->word);
         Category::create(["name" => $name]);
     }
 }
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         $word = $faker->word;
         Category::create(['name' => $word, 'slug' => $word . $index]);
     }
 }
 public function run()
 {
     DB::table('categories')->truncate();
     $faker = Factory::create();
     foreach (range(1, 3) as $category) {
         Category::create(['name' => $faker->word]);
     }
 }
Пример #24
0
 public function postIndex()
 {
     Former::populate(Input::all());
     if ($category = Category::create(Input::except('_token'))) {
         return Redirect::to(admin_path('categories/edit/' . $category->id));
     }
     return self::getIndex();
 }
Пример #25
0
 public function run()
 {
     //DB::table('categories')->delete();
     $categories = array(array('type' => 'video', 'group_category_id' => 1, 'name' => 'ent'), array('type' => 'video', 'group_category_id' => 1, 'name' => 'music'), array('type' => 'video', 'group_category_id' => 1, 'name' => 'sing'), array('type' => 'video', 'group_category_id' => 1, 'name' => 'play'), array('type' => 'video', 'group_category_id' => 1, 'name' => 'dance'), array('type' => 'video', 'group_category_id' => 1, 'name' => 'vocaloid'), array('type' => 'video', 'group_category_id' => 1, 'name' => 'nicoindies'), array('type' => 'video', 'group_category_id' => 2, 'name' => 'animal'), array('type' => 'video', 'group_category_id' => 2, 'name' => 'cooking'), array('type' => 'video', 'group_category_id' => 2, 'name' => 'nature'), array('type' => 'video', 'group_category_id' => 2, 'name' => 'travel'), array('type' => 'video', 'group_category_id' => 2, 'name' => 'sport'), array('type' => 'video', 'group_category_id' => 2, 'name' => 'lecture'), array('type' => 'video', 'group_category_id' => 2, 'name' => 'drive'), array('type' => 'video', 'group_category_id' => 2, 'name' => 'history'), array('type' => 'video', 'group_category_id' => 3, 'name' => 'politics'), array('type' => 'video', 'group_category_id' => 4, 'name' => 'science'), array('type' => 'video', 'group_category_id' => 4, 'name' => 'tech'), array('type' => 'video', 'group_category_id' => 4, 'name' => 'handcraft'), array('type' => 'video', 'group_category_id' => 4, 'name' => 'make'), array('type' => 'video', 'group_category_id' => 5, 'name' => 'anime'), array('type' => 'video', 'group_category_id' => 5, 'name' => 'game'), array('type' => 'video', 'group_category_id' => 5, 'name' => 'toho'), array('type' => 'video', 'group_category_id' => 5, 'name' => 'imas'), array('type' => 'video', 'group_category_id' => 5, 'name' => 'radio'), array('type' => 'video', 'group_category_id' => 5, 'name' => 'draw'), array('type' => 'video', 'group_category_id' => 6, 'name' => 'are'), array('type' => 'video', 'group_category_id' => 6, 'name' => 'diary'), array('type' => 'video', 'group_category_id' => 6, 'name' => 'other'), array('type' => 'video', 'group_category_id' => 7, 'name' => 'r18'), array('type' => 'illust', 'group_category_id' => 8, 'name' => 'original'), array('type' => 'illust', 'group_category_id' => 8, 'name' => 'portrait'), array('type' => 'illust', 'group_category_id' => 9, 'name' => 'anime'), array('type' => 'illust', 'group_category_id' => 9, 'name' => 'game'), array('type' => 'illust', 'group_category_id' => 9, 'name' => 'character'), array('type' => 'illust', 'group_category_id' => 10, 'name' => 'toho'), array('type' => 'illust', 'group_category_id' => 10, 'name' => 'vocaloid'), array('type' => 'illust', 'group_category_id' => 11, 'name' => 'r15'), array('type' => 'illust', 'group_category_id' => 11, 'name' => 'gro'));
     foreach ($categories as $category) {
         Category::create(array('type' => $category['type'], 'group_category_id' => $category['group_category_id'], 'content' => $category['name']));
     }
 }
Пример #26
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Eloquent::unguard();
     DB::table('categories')->delete();
     Category::create(array('name' => 'glasses'));
     Category::create(array('name' => 'jackets'));
     Category::create(array('name' => 'cars'));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param $id
  * @return Response
  */
 public function store($id)
 {
     $commentable_id = Input::get('commentable_id');
     $commentable_type = Input::get('commentable_type');
     $val = $this->commentRepository->getCreateForm();
     if (!$val->isValid()) {
         return Redirect::back()->withInput()->withErrors($val->getErrors());
     }
     if (!($record = $this->commentRepository->create(array_merge(['user_id' => Auth::user()->id, 'commentable_id' => $commentable_id, 'commentable_type' => $commentable_type], $val->getInputData())))) {
         return Redirect::back()->with('errors', $this->commentRepository->errors())->withInput();
     }
     if ($commentable_type == 'EventModel') {
         return Redirect::action('EventsController@show', $id)->with('success', trans('word.comment_posted'));
     } else {
         return Redirect::action('BlogsController@show', $id)->with('success', trans('word.comment_posted'));
     }
 }
Пример #28
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Eloquent::unguard();
     Product::create(['name' => 'Test Product', 'slug' => 'test-product', 'price' => 100, 'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent rhoncus, turpis ac imperdiet dapibus, leo orci gravida neque, in malesuada elit libero eu sapien. Mauris sed sapien id sapien bibendum luctus et eu massa. Nulla egestas interdum magna non dignissim. Sed a laoreet purus, non rutrum augue. Proin laoreet eros nec elit mattis euismod. Aliquam facilisis, lacus blandit iaculis accumsan, leo quam sagittis nisi, non dapibus arcu libero efficitur turpis. In fringilla est nec sapien tempus suscipit. Suspendisse eget justo risus.']);
     Product::create(['name' => 'Uncategorized Product', 'slug' => 'uncategorized-product', 'price' => 200, 'description' => 'This product has no category.']);
     Category::create(['name' => 'Test Category', 'slug' => 'test-category']);
     ProductCategory::create(['product_id' => 1, 'category_id' => 1]);
 }
Пример #29
0
 /**
  * Store a newly created category in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make($data = Input::all(), Category::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     Category::create($data);
     return Redirect::route('categories.index');
 }
Пример #30
0
 /** 
  *	Them category
  *	@var string name
  *	@return boolean
  */
 public static function addCategory($name)
 {
     $result = Category::create(['name' => $name]);
     if (isset($result)) {
         return true;
     } else {
         return false;
     }
 }