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


PHP Category::save方法代碼示例

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


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

示例1: ajaxStore

 public function ajaxStore(Request $request)
 {
     $this->validate($request, ['new-post-category' => 'required']);
     $category = new Category(array('title' => $request->get('new-post-category'), 'slug' => str_slug($request->get('new-post-category'))));
     $category->save();
     return $this->getAllCategories();
 }
開發者ID:leloulight,項目名稱:RealMadrid,代碼行數:7,代碼來源:CategoryController.php

示例2: cat_add

 public function cat_add(Request $request)
 {
     // Si je suis en POST
     // Validator
     // fail
     // Enregistrement en BDD
     // Message flash
     if ($request->isMethod('POST')) {
         $validator = Validator::make($request->all(), ['InputT' => 'required', 'InputD' => 'required', 'InputP' => 'required', 'img' => 'image'], ['InputT.required' => 'Attention le champ titre est vide', 'InputD.required' => 'Attention la description est vide', 'InputP.required' => 'Attention le champ position est vide']);
         if ($validator->fails()) {
             return redirect()->route('route_cat_add')->withInput()->withErrors($validator);
         }
         $file = $request->file('img');
         $destinationFile = public_path() . '/uploads/categories';
         $nameFile = str_random(15) . '.' . $file->getClientOriginalExtension();
         $nouvelleCategorie = new Category();
         $nouvelleCategorie->name = $request->InputT;
         $nouvelleCategorie->description = $request->InputD;
         $nouvelleCategorie->position = $request->InputP;
         $nouvelleCategorie->image = $nameFile;
         $nouvelleCategorie->save();
         // Fait l'enregistrement en BDD
         $file->move($destinationFile, $nameFile);
         return redirect()->route('route_cat_add')->with('success', 'Votre catégorie a bien été ajoutée');
     }
     return view('admin/ajout-cat');
 }
開發者ID:totof974,項目名稱:laravel,代碼行數:27,代碼來源:AdminController.php

示例3: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(CategoryRequest $request)
 {
     $category = new Category($request->all());
     $category->save();
     Flash::success("La categoria " . $category->name . " fue registrada con éxito");
     return redirect()->route('admin.categories.index');
 }
開發者ID:blitzkriegcoding,項目名稱:blog_cf,代碼行數:13,代碼來源:CategoriesController.php

示例4: postAdd

 public function postAdd(Request $request)
 {
     $validator = $this->validatorForAdd($request->all());
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator->messages())->withInput();
     }
     $category = new Category();
     $category->name = $request->input('name');
     $category->table_name = Slug::make($request->input('name'));
     if ($request->input('parent_id') != "") {
         $category->parent_id = $request->input('parent_id');
     }
     $category->description = $request->input('description');
     $category->final = $request->input('final');
     $category->num_columns = $request->input('num_columns');
     $category->type = $request->input('type');
     $file = $request->file('image');
     $imageExtension = $file->getClientOriginalExtension();
     $imageName = $category->table_name . '.' . $imageExtension;
     $request->file('image')->move(base_path() . '/public/images/categories/', $imageName);
     $category->image = $imageName;
     if ($category->final == 0 || $category->type != 0) {
         $category->save();
         $msg = "Категория \"" . $category->name . "\" добавлена.";
         return redirect('admin/category?type=' . $request->input('type'))->with('msg', $msg);
     } else {
         $request->session()->flash('category', $category);
         return redirect('admin/category/addcolumns');
     }
 }
開發者ID:GorshkovNikita,項目名稱:ruchaicof,代碼行數:30,代碼來源:CategoriesController.php

示例5: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(CategoryRequest $request)
 {
     $category = new Category();
     // if ($request->hasFile('image'))
     // {
     //     $image = $request->file('image')->getClientOriginalName();
     //     $request->file('image')->move('img/categories/', $image);
     // }
     // else
     // {
     //     $image = 'no-image';
     // }
     $count = $category->count();
     if ($request->sort_id > 0) {
         $category->sort_id = $request->sort_id;
     } else {
         $category->sort_id = ++$count;
     }
     $category->section_id = $request->section_id;
     $category->title = $request->title;
     $category->slug = !empty($request->slug) ? $request->slug : str_slug($request->title);
     $category->image = $request->image;
     $category->title_description = $request->title_description;
     $category->meta_description = $request->meta_description;
     $category->text = $request->text;
     if ($request->status == 'on') {
         $category->status = 1;
     } else {
         $category->status = 0;
     }
     $category->save();
     return redirect('/admin/categories')->with('status', 'Категория добавлена!');
 }
開發者ID:vizovteam,項目名稱:vizov,代碼行數:38,代碼來源:AdminCategoriesController.php

示例6: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $category = new Category();
     $category->category_name = $request->category_name;
     $category->save();
     \Session::flash('success', 'Category created successfully');
 }
開發者ID:pius-ng3a,項目名稱:go_orderdeliver,代碼行數:13,代碼來源:CategoryController.php

示例7: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     // Validation //
     $validation = Validator::make($request->all(), ['name' => 'required|unique:categories|max:255', 'description' => 'required']);
     // Check if it fails //
     if ($validation->fails()) {
         return redirect()->back()->withInput()->with('errors', $validation->errors());
     }
     if ($request->input('publish') == "") {
         $publish = 0;
     } else {
         $publish = 1;
     }
     $author = Auth::user()->id;
     $category = new Category();
     $seo = $request->input('name');
     $seotitle = SeoHelper::seotitle($seo);
     // save category data into database //
     $category->name = $request->input('name');
     $category->name_seo = $seotitle;
     $category->id_user = $author;
     $category->description = $request->input('description');
     $category->publish = $publish;
     $category->save();
     Alert::success('Success Create ' . $request->input('name') . ' !')->persistent("Close");
     return redirect('dropmin/category/list')->with('message', 'You just create categories!');
 }
開發者ID:arisros,項目名稱:drope.com,代碼行數:33,代碼來源:CategoryController.php

示例8: insert_category

 public function insert_category(Request $request)
 {
     $cat = new Category();
     $cat->cat_name = $request->input('cname');
     $cat->remarks = $request->input('remarks');
     $cat->save();
 }
開發者ID:nilesh93,項目名稱:Distribution_Management_System,代碼行數:7,代碼來源:CategoryController.php

示例9: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $category1 = new Category();
     $category1->name = 'Cat 1';
     $category1->save();
     $category2 = new Category();
     $category2->name = 'Cat 2';
     $category2->save();
     $nice_action = new NiceAction();
     $nice_action->name = 'Greet';
     $nice_action->niceness = 3;
     $nice_action->save();
     $category1->nice_actions()->attach($nice_action);
     $category2->nice_actions()->attach($nice_action);
     $nice_action = new NiceAction();
     $nice_action->name = 'Hug';
     $nice_action->niceness = 6;
     $nice_action->save();
     $category2->nice_actions()->attach($nice_action);
     $nice_action = new NiceAction();
     $nice_action->name = 'Kiss';
     $nice_action->niceness = 12;
     $nice_action->save();
     $category1->nice_actions()->attach($nice_action);
     $nice_action = new NiceAction();
     $nice_action->name = 'Wave';
     $nice_action->niceness = 2;
     $nice_action->save();
     $category2->nice_actions()->attach($nice_action);
 }
開發者ID:pedreyesjr,項目名稱:test,代碼行數:35,代碼來源:NiceActionSeeder.php

示例10: updateCategories

 public function updateCategories(Request $request)
 {
     foreach ($request->all() as $id => $data) {
         if ($id !== '_token') {
             if ($data['type'] == 'remove' && $id >= 1) {
                 $found = Category::findOrFail($id);
                 if ($found->products->isEmpty()) {
                     $found->delete();
                 }
             } else {
                 if ($data['name'] !== '' && $data['type'] !== '') {
                     if ($id >= 1) {
                         $found = Category::findOrFail($id);
                     } else {
                         $found = new Category();
                     }
                     $found->name = $data['name'];
                     $found->type = $data['type'];
                     $found->save();
                 }
             }
         }
     }
     return redirect()->route('categories.index');
 }
開發者ID:jhruby23,項目名稱:barapp,代碼行數:25,代碼來源:AdminController.php

示例11: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $category = new Category();
     $category->name = $request->name;
     $category->save();
     return redirect('movie');
 }
開發者ID:kevinrefvik,項目名稱:MovieCatalogue,代碼行數:13,代碼來源:CategoryController.php

示例12: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $category = new Category();
     $category->fill($request->all());
     $image = $request->file('image');
     $imageName = "";
     if ($image->isValid()) {
         $path = public_path() . '/uploads/category/';
         $imageName = str_random(32) . '.' . $image->getClientOriginalExtension();
         $image->move($path, $imageName);
     } else {
         App::abort(404);
     }
     $small_image = $request->file('small_image');
     $imageNamesmall = "";
     if ($small_image->isValid()) {
         $path = public_path() . '/uploads/category/';
         $imageNamesmall = str_random(32) . '.' . $small_image->getClientOriginalExtension();
         $small_image->move($path, $imageNamesmall);
     } else {
         App::abort(404);
     }
     $category->image = $imageName;
     $category->small_image = $imageNamesmall;
     $category->save();
     return Redirect::route('admin.category.show');
 }
開發者ID:nikajorjika,項目名稱:gamoiwere.ge,代碼行數:33,代碼來源:CategoryController.php

示例13: store

 public function store(CategoryRequest $request)
 {
     $cat = new Category($request->all());
     $cat->save();
     Flash::success("Se ha registrado una nueva categoría " . $cat->name . " de manera exitosa!");
     return redirect()->route('admin.categories.index');
 }
開發者ID:gratereaux,項目名稱:practicing-laravel,代碼行數:7,代碼來源:CategoriesController.php

示例14: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $validator = Validator::make($request->all(), ['name' => 'unique:categories,name', 'image' => 'mimes:jpeg,png,jpg', 'promotion_image' => 'mimes:jpeg,jpg,png']);
     if ($validator->fails()) {
         return redirect('categories/create')->withErrors($validator)->withInput();
     }
     $image = Input::file('image');
     $filename = date('YmdHis') . "-" . $image->getClientOriginalName();
     if ($request->hasFile('promotion_image')) {
         $promotion_image = Input::file('promotion_image');
         $promotion_filename = date('YmdHis') . "-PI-" . $promotion_image->getClientOriginalName();
         $request->file('promotion_image')->move(base_path() . '/public/admin/productimage/', $promotion_filename);
     } else {
         $promotion_filename = "";
     }
     if ($request->has('active')) {
         $categories = new Category(array('name' => $request->get('name'), 'active' => "Enable", 'color' => $request->get('color'), 'image' => $filename, 'promotion_image' => $promotion_filename));
         $request->file('image')->move(base_path() . '/public/admin/productimage/', $filename);
         $categories->save();
     } else {
         $categories = new Category(array('name' => $request->get('name'), 'color' => $request->get('color'), 'image' => $filename, 'promotion_image' => $promotion_filename));
         $request->file('image')->move(base_path() . '/public/admin/productimage/', $filename);
         $categories->save();
     }
     return redirect('categories');
 }
開發者ID:hafizzain,項目名稱:mei-project,代碼行數:32,代碼來源:CategoryController.php

示例15: importCategory

 public static function importCategory($request)
 {
     $new_category = new Category();
     $new_category->name = $request->get("name");
     //$new_category->deleted_at = $request->get('deleted_at');
     $new_category->save();
 }
開發者ID:encry2024,項目名稱:inv_5_2,代碼行數:7,代碼來源:Category.php


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