【发布时间】:2015-03-24 06:53:00
【问题描述】:
我尝试使用 php Laravel 框架创建应用程序。当我在 路由文件中使用 Auth::user()->id > 我收到错误“尝试获取非对象的属性”。那么我该如何解决呢?
这是我的路线文件
`
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', 'HomeController@index');
Route::controllers([
'auth' => 'Auth\AuthController',
'password' => 'Auth\PasswordController',
]);
$common_variable=App\MyModel::where('site_id',Auth::user()->id)->count();
view()->share(compact('common_variable'));
`
【问题讨论】:
-
您有查询的解决方案吗?
标签: php authentication laravel-5