Laravel + Passport api 通过 Auth 获取记录
Laravel + Passport api get records by Auth
问题是我想通过 Auth::user()->部门记录 如何在 Laravel api + Passport.
中解决这个问题
"message": "Class 'App\Http\Controllers\API\Auth' not found",
Controller/Api/ApiController.php
public function index(){
$banks = Bank::where('bank', Auth::user()->department)->orderby("created_at",'desc')->get();
return $this->sendResponse($banks->toArray(), 'Амжилттай уншигдлаа.');
}
That's it, You just need to add Auth Class in your php file.
use \Auth;
问题是我想通过 Auth::user()->部门记录 如何在 Laravel api + Passport.
中解决这个问题"message": "Class 'App\Http\Controllers\API\Auth' not found",
Controller/Api/ApiController.php
public function index(){
$banks = Bank::where('bank', Auth::user()->department)->orderby("created_at",'desc')->get();
return $this->sendResponse($banks->toArray(), 'Амжилттай уншигдлаа.');
}
That's it, You just need to add Auth Class in your php file.
use \Auth;