Laravel 5.5为什么产品页面是空的?

时间:2017-12-28 14:23:45

标签: php laravel laravel-5.5

我想展示我的产品。一切似乎都很好,但每次都会将产品页面打开为空白页面。我在哪里弄错了?

路线;

Route::get('product/{slug}',['as'=>'product.show','uses'=>'ProductController@getProduct']);

控制器;

public function getProduct($slug){

        $product = Product::where('product_slug',$slug)->first();

        return view('frontend.product',compact('product'));
    }

我在我的产品刀片中尝试了dd方法。然后它给了我这个错误

file_put_contents(/var/www/laravel/storage/framework/views/7cdf86b0b5c552ccae1fab5d7990ec98a9c7cc32.php): failed to open stream: Permission denied

2 个答案:

答案 0 :(得分:1)

您需要运行此命令以允许Laravel为视图创建缓存:

chmod -R 755 ./storage

来自the docs

  

目录权限

     

安装Laravel后,您可能需要配置一些权限。 storagebootstrap/cache目录中的目录应该可以由您的Web服务器写入,否则Laravel将无法运行。如果您使用的是Homestead虚拟机,则应已设置这些权限。

https://laravel.com/docs/5.5#configuration

答案 1 :(得分:0)

您可以尝试_assign () 或者在视图返回之前在方法中设置php artisan view:clear以查看它是否会触发。

相关问题