抛出新的InvalidArgumentException(“找到的视图[admin.product.edit_product]。”);

时间:2019-09-10 16:21:17

标签: laravel laravel-5.6 laravel-5.7

Applications / XAMPP / xamppfiles / htdocs / admin_panel / vendor / laravel / framework / src / Illuminate / View / FileViewFinder.php

    /**
     * Find the given view in the list of paths.
     *
     * @param  string  $name
     * @param  array   $paths
     * @return string
     *
     * @throws \InvalidArgumentException
     */
    protected function findInPaths($name, $paths)
    {
        foreach ((array) $paths as $path) {
            foreach ($this->getPossibleViewFiles($name) as $file) {
                if ($this->files->exists($viewPath = $path.'/'.$file)) {
                    return $viewPath;
                }
            }
        }

        throw new InvalidArgumentException("View [admin.product.edit_product] found.");
    }

    /**
     * Get an array of possible view files.
     *
     * @param  string  $name
     * @return array
     */
    protected function getPossibleViewFiles($name)
    {
        return array_map(function ($extension) use ($name) {
            return str_replace('.', '/', $name).'.'.$extension;

参数

"View [admin.product.edit_product] found."

https://drive.google.com/file/d/11W45UPAN_6xEZx_OkrzEcHaa3AIqU7Ta/view?usp=sharing

公共功能editProduct(Request $ request,$ id = null){

    if ($request->isMethod('post')) {
        $data = $request->all();
        /*echo "<pre>"; print_r($data); die;*/
        Product::where(['id'=>$id])->update(['category_id'=>$data['category_id'],'product_name'=>$data['product_name'],'product_code'=>$data['product_code'],'product_color'=>$data['product_color'],'description'=>$data['description'],'price'=>$data['price']]);
        return redirect()->back()->with('flash_message_success','Product has been updated successfully!');
    }
    // Get Product Details
    $productDetails = Product::where(['id'=>$id])->first();

    // Categories drop down start
    $categories = Category::where(['parent_id'=>0])->get();
    $categories_dropdown = "<option value='' selected disabled>Select</option>";
    foreach($categories as $cat){
        if($cat->id==$productDetails->category_id){
            $selected = "selected";
        }else{
            $selected = "";
        }
        $categories_dropdown .= "<option value='".$cat->id."' ".$selected.">".$cat->name."</option>";
        $sub_categories = Category::where(['parent_id'=>$cat->id])->get();
        foreach ($sub_categories as $sub_cat) {
            if($sub_cat->id==$productDetails->category_id){
            $selected = "selected";
        }else{
            $selected = "";
        }
            $categories_dropdown .= "<option value = '".$sub_cat->id."' ".$selected."
            >&nbsp;--&nbsp;".$sub_cat->name."</option>";
        }
    }
    // Categories drop down ends

    return view('admin.products.edit_product')->with(compact('productDetails','categories_dropdown'));
}

请帮助我谢谢

0 个答案:

没有答案