本文整理汇总了PHP中app\Product::fill方法的典型用法代码示例。如果您正苦于以下问题:PHP Product::fill方法的具体用法?PHP Product::fill怎么用?PHP Product::fill使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Product
的用法示例。
在下文中一共展示了Product::fill方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(ProductRequest $request)
{
$product = new Product();
$product->fill($request->all());
$product->section = str_replace('products.', '', $request->section);
$product->save();
return redirect(route($request->section))->with('message', 'Producto creado corectamente');
}
示例2: update
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function update(Request $request, Product $product)
{
$product->fill($request->all());
$product->slug = str_slug($request->get('name'));
$product->visible = $request->has('visible') ? 1 : 0;
$updated = $product->save();
$message = $updated ? 'Producto actualizado correctamente!' : 'El producto NO pudo actualizarse!';
return redirect()->route('admin.product.index')->with('message', $message);
}
示例3: update
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function update(SaveProductRequest $request, Product $product)
{
$product->fill($request->all());
$product->slug = str_slug($request->get('name'));
$product->visible = $request->has('visible') ? 1 : 0;
$updated = $product->save();
$message = $updated ? 'Product was updated successfully!' : 'Could not update product!';
return redirect()->route('admin.product.index')->with('message', $message);
}
示例4: update
/**
* Update the specified resource in storage.
*
*/
public function update(SaveProductRequest $request, Product $product)
{
$product->fill($request->all());
$product->slug = str_slug($request->get('name'));
$product->visible = $request->has('visible') ? 1 : 0;
$updated = $product->save();
$message = $updated ? "Producto actualizado" : "Error al actualizar";
return redirect()->route('admin.product.index')->with('message', $message);
}
示例5: update
/**
* Update the specified resource in storage.
*
* @param Product $product
* @return Response
*/
public function update($product)
{
$product->fill(Input::data());
if (Input::data('module') && ($module = Module::find(Input::data('module')['id']))) {
$product->module()->associate($module);
}
$product->save();
return $product;
}
示例6: store
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
$a = new Product();
if (!$a->validate(Input::all())) {
return redirect('product/create')->withErrors($a->errors())->withInput();
}
$a->fill(Input::all());
$a->save();
Flash::success('New product is created');
return Redirect::to('product');
}
示例7: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$object = new Model();
$params = $request->only('img', 'slider_img', 'ru_slider', 'en_slider', 'ua_slider', 'product_category_id', 'unit_id', 'ru_title', 'ru_description', 'ru_file', 'ru_seo_title', 'ru_seo_keywords', 'ru_seo_description', 'en_title', 'en_description', 'en_file', 'en_seo_title', 'en_seo_keywords', 'en_seo_description', 'ua_title', 'ua_description', 'ua_file', 'ua_seo_title', 'ua_seo_keywords', 'ua_seo_description');
$filter = $object->validator($params);
if ($filter->fails()) {
if ($request->ajax()) {
return $this->responseAnswer(true, $params, $filter->errors());
} else {
$error = $filter->errors()->toArray();
$categories = ProductCategory::all();
$units = Unit::all();
return view('admin.product.create', ['input' => $params, 'categories' => $categories, 'units' => $units, 'error' => $error]);
}
}
if ($request->hasFile('img')) {
$params['img'] = $this->upload('img');
}
if ($request->hasFile('slider_img')) {
$params['slider_img'] = $this->upload('slider_img');
}
if ($request->hasFile('ru_file')) {
$params['ru_file'] = $this->uploadPdf('ru_file');
}
if ($request->hasFile('en_file')) {
$params['en_file'] = $this->uploadPdf('en_file');
}
if ($request->hasFile('ua_file')) {
$params['ua_file'] = $this->uploadPdf('ua_file');
}
$params['on_top'] = $request->has('on_top');
$params['alias'] = $this->makeAlias($params['ru_title']);
$object->fill($params);
$object->save();
$category = ProductCategory::find($params['product_category_id']);
$category->count = DB::table('products')->where('product_category_id', '=', $params['product_category_id'])->where('deleted_at', '=', NULL)->count();
$category->save();
if ($request->ajax()) {
return $this->responseAnswer(false, $object);
} else {
return redirect('admin/product/' . $object->id . '/edit');
}
}
示例8: saveProduct
private function saveProduct(Request $request, Product $product)
{
$validator = Product::validate($request->all());
if ($validator->fails()) {
return redirect(route(Route::currentRouteName()))->withErrors($validator->errors());
} else {
if (!is_null($product->id)) {
$product->update($request->all());
Session::flash('success', "Le produit a bien été mis à jour.");
} else {
$product->fill($request->all());
$product->save();
Session::flash('success', "Le produit a bien été crée.");
}
}
if ($param = Route::current()->getParameter('id')) {
return redirect()->route(Route::currentRouteName(), $param);
}
return redirect()->route(Route::currentRouteName());
}
示例9: update
public function update(Request $request, Product $product)
{
$insert = $product->fill($request->input())->save();
$image = \Input::get('image');
if ($image != '') {
$imagename = 'product-' . rand(11111, 99999) . '-gudperna.png';
$image = str_replace(' ', '+', $image);
list($type, $image) = explode(';', $image);
list(, $image) = explode(',', $image);
$image = base64_decode($image);
file_put_contents('upload/img/' . $imagename, $image);
$product->image = $imagename;
$product->save();
}
if ($insert) {
return 0;
} else {
return 1;
}
}
示例10: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Product $product, Request $request)
{
//
$data = $request->all();
$data['created_by'] = \Auth::user()->id;
$data['updated_by'] = \Auth::user()->id;
$data['is_active'] = 1;
if (Input::file('image')) {
$destinationPath = 'img/product';
// upload path
$extension = Input::file('image')->getClientOriginalExtension();
// getting image extension
$fileName = rand(11111, 99999) . '.' . $extension;
// renameing image
$data['photo'] = $fileName;
Input::file('image')->move($destinationPath, $fileName);
// uploading file to given path
}
$product->fill($data)->save();
return Redirect::route('products.index');
}
示例11: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
// parse url
$url = $this->parseURLPDF();
// Parse pdf file and build necessary objects.
$parser = new \Smalot\PdfParser\Parser();
$pdf = $parser->parseFile($url);
$pages = $pdf->getPages();
foreach ($pages as $page) {
$p = new ParsePage($page->getArray());
$products = $p->parseProducts();
foreach ($products as $product) {
$p = Product::whereCode($product['code'])->first();
if (is_null($p)) {
$p = new Product();
}
$p->fill($product);
$p->save();
}
}
}