本文整理汇总了PHP中app\Category::fill方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::fill方法的具体用法?PHP Category::fill怎么用?PHP Category::fill使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Category
的用法示例。
在下文中一共展示了Category::fill方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param Category $category
* @return \Illuminate\Http\Response
*/
public function store(Request $request, Category $category)
{
$this->validate($request, ['name' => 'required|unique:categories', 'slug' => 'required|unique:categories']);
$input = $request->except(['_token']);
$category->fill($input)->save();
return redirect('categories')->with('success', $category->name . ' category successfully added.');
}
示例2: 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');
}
示例3: update
/**
* Update the specified resource in storage.
*
*/
public function update(Request $request, Category $category)
{
$category->fill($request->all());
$category->slug = str_slug($request->get('name'));
$updated = $category->save();
$message = $updated ? 'Categoria actualizada' : 'Error al actualizar';
return redirect()->route('admin.category.index')->with('message', $message);
}
示例4: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update(Request $request, Category $category)
{
$category->fill($request->all());
$category->slug = str_slug($request->get('name'));
$updated = $category->save();
$message = $updated ? 'Category was updated succesfully' : 'Could not update the new category';
return redirect()->route('admin.category.index')->with('message', $message);
}
示例5: store
/**
* Store a newly created resource in storage.
*
* @param CreateCategoryRequest $request
* @return Response
*/
public function store(CreateCategoryRequest $request)
{
$category = new Category();
$category->fill($request->all());
$category->save();
$message = trans('messages.category_created_successfully');
Flash::success($message);
return redirect()->route('admin.categories.index');
}
示例6: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update(Request $request, Category $category)
{
$this->validate($request, ['name' => 'required|max:255', 'color' => 'required']);
$category->fill($request->all());
$category->slug = str_slug($request->get('name'));
$updated = $category->save();
$message = $updated ? 'Categoría actualizada correctamente!' : 'La Categoría NO pudo actualizarse!';
return redirect()->route('admin.category.index')->with('message', $message);
}
示例7: pushCategory
/**
* Create a new category from request.
*
* @param $request input form data
* @return User
*/
public function pushCategory($request)
{
$input = $request->all();
if (isset($input['name'])) {
$input['slug'] = str_slug($input['name'], "-");
}
$category = new Category();
$category->fill($input);
$category->save();
return $category;
}
示例8: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
// $dropbox = Dropbox::createTemporaryDirectLink("/web/test.jpg");
//
// return $dropbox;
$this->validate($request, ['slug' => 'unique:categories,slug', 'name' => 'required', 'description' => 'required']);
$category = new Category();
$category->fill($request->all());
if ($request->hasFile('featured_image')) {
$file = $request->file('featured_image');
$timestamp = str_replace([' ', ':'], '-', Carbon::now()->toDateTimeString());
$name = $timestamp . '.' . $file->getClientOriginalExtension();
$path = "/web/categories/";
$dropbox = Dropbox::uploadFileFromString($path . $name, Dropbox\WriteMode::add(), file_get_contents($request->file('featured_image')->getRealPath()));
$category->featured_image = $dropbox['path'];
}
$category->save();
Session::flash('flash_message', 'Flokkurinn var vistaður');
return redirect()->back();
}
示例9: update
/**
* Updates Category into database
*
* @param Category $category
* @param array $input
*
* @return Category
*/
public function update($category, $input)
{
$category->fill($input);
$category->save();
return $category;
}
示例10: update
/**
* Update the specified category in storage.
*
* @param Category $category
* @param CategoryRequest $request
* @return Response
*/
public function update(Category $category, CategoryRequest $request)
{
$category->fill($request->all());
$category->save() ? Flash::success(trans('admin.update.success')) : Flash::error(trans('admin.update.fail'));
return redirect(route('admin.category.index'));
}