在运行http://127.0.0.1:8000/products时,显示未找到products.index

时间:2018-12-06 13:15:33

标签: laravel-5.6

文件目录:C:\ laragon \ www \ first-laravel-app \ 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 [{$name}] not 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;
    }, $this->extensions);
}

/**
 * Add a location to the finder.
 *
 * @param  string  $location
 * @return void

参数 “未找到“查看[products.index]”。

尝试访问http://127.0.0.1:8000/products处的页面时,显示未找到products.index。

1 个答案:

答案 0 :(得分:0)

由于要初始化route as a resource,因此需要为ProductController类中的每种可能的路线定义方法。

请参阅:Laravel - Route::resource vs Route::controller