sar*_* lk 5 php authentication laravel-5
我尝试使用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'));
Run Code Online (Sandbox Code Playgroud)
`
| 归档时间: |
|
| 查看次数: |
12324 次 |
| 最近记录: |