Elliot
Elliot

Reputation: 580

Laravel + Passport api get records by Auth

Problem is i want to take records by Auth::user()->department How to solve this problem in 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(), 'Амжилттай уншигдлаа.');
}

Upvotes: 1

Views: 322

Answers (1)

Ruka Xing
Ruka Xing

Reputation: 642

That's it, You just need to add Auth Class in your php file.

use \Auth;

Upvotes: 1

Related Questions