i have a laravel app that uses laravel passport and vue.js for the front-end. Currently when i show a list from the database it shows all the elements of the table and i want it to show me only the data from the current user
I've seen that this function is made in the controller
public function index()
{
$prospect = prospect::all();
return $prospect;
}
In the database table i have a variable 'Salesman' that equals to the variable 'first' of current user
do you now how can i achieve this?
If the route is inside an 'auth' middleware, you should be able to use the Auth facade, and limit your query as so:
public function index() {
$prospects = Prospect::where('user_id', Auth::id())->get();
return $prospects;
}