运行http://127.0.0.1:8000/products时,提示products.index not found

问题描述 投票:0回答:1

文件目录:C:\larragon\www irst-laravel-app endor\laravel ramework\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

论点 “找不到[产品.索引]。”

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

php laravel-5
1个回答
0
投票

因为您正在将路由初始化为资源,所以您需要为 ProductController 类中的每个可能的路由定义方法。

参见:Laravel - Route::resource 与 Route::controller

© www.soinside.com 2019 - 2024. All rights reserved.