函数 str_slug 已弃用且无法正常工作,我该怎么办?

function str_slug is deprecated and not working, what should i do?

我试图使用 Str_slug,但它在 laravel 5.8 中不起作用。 我正在使用最新版本的 PhpStorm。

$product->slug = Str_slug('$request->title');

Check the image for more

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');
}

您应该使用 Str::slug() (Illuminate\Support\Str) 而不是弃用的 str_slug()

https://laravel.com/docs/5.8/helpers#method-str-slug