本文整理汇总了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();
}
示例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');
}
示例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');
}
示例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');
}
}
示例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', 'Категория добавлена!');
}
示例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');
}
示例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!');
}
示例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();
}
示例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);
}
示例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');
}
示例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');
}
示例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');
}
示例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');
}
示例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');
}
示例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();
}