我正在使用Laravel 5,并且我已经创建了一个非常基本的应用程序。这个想法是允许用户免费注册,但在那之后,他们必须订阅两个计划中的一个才能使用额外的功能。
使用Laravel内置的Auth,用户登录后会被带到/home(home.blade.php)。在这里我想检查用户是否订阅了。
有一个方法:$user->subscribed()
,但在我的视图中如何访问它?Auth
在视图中可用,但subscribed()
不是一种方法——我(错误地)认为Auth
将包含当前登录的$user
的副本。
下面是我想要实现的一个例子:
@if (Auth::subscribed())
You are subscribed!
@else
You haven't subscribed yet
@endif
@if (Auth::user()->subscribed())
试试看。
根据http://laravel.com/docs/5.0/billing它应该起作用。