无法在控制器laravel5.6的子文件夹中获取当前登录的用户ID
已添加控制器中
use Illuminate\Support\Facades\Auth;
试图通过使用Auth::user()->user_id;
来获取,但返回null
namespace App\Http\Controllers\API;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\User;
use Illuminate\Support\Facades\Auth;
class IndexController extends Controller
{
public function index(){
return Auth::user()->id;
}
}