我试图使用Str_slug,但是在laravel 5.8中不起作用。 我正在使用PhpStorm最新版本。
$ product-> slug = Str_slug('$ request-> title');
public function ProductStore(StoreValidation $request){
$product = new product();
$product->category_id = 1;
$product->brand_id = 1;
$product->title = $request->title;
$product->desc = $request->desc;
$product->slug = Str_slug('$request->title');
$product->quantity = $request->quantity;
$product->price = $request->price;
$product->offer_price = $request->offer;
$product->status = 1;
$product->admin_id = 1;
// Saving Product information into product table
$product->save();
if ($request->hasFile('uploadFile')){
$image = $request->file('uploadFile');
$img = time() . '.' . $image->getClientOriginalExtension();
$location = public_path('image/product/' .$img);
$img_ins = Image::make($image)->resize(220,294);
$img_ins->save($location);
$product_img = new product_image();
$product_img->product_id = $product->id;
$product_img->image_name = $img;
$product_img->save();
}
return redirect()->route('admin_panel.pages.admin-addProduct');
}
答案 0 :(得分:0)
您应该使用Str::slug()
(Illuminate \ Support \ Str)而不是不推荐使用的str_slug()
。