Filter database - dropdow (selct data source) secssion userid

Filter from select list based on owner session is not working.

n my case, for example, I have a list of cars, but each car belongs to only one client, one client has several cars for rent.

when the customer is going to rent he can only list the cars that belong to his user id, in this case I already have the car owner’s foreign key in the car table.

when renting a car the customer can only list what belongs to him based on the user’s login session.

@snarthost that is used for binding data to your query. Please write your query and use : to specify the fields you want to bind and Radsystems will automatically show the variable you can pass a value to below.

Example:
writing a query like this

 SELECT id as value, company_name as lable FROM company WHERE rel_uid = :uid

on the Query Parameter section, you will see/add something like this.

query_params['uid'] = auth()->user()->user_id; // where auth()->user()->user_id is the value/variable you want to bind to the :uid parameter.
1 Like

Thank you very much for the answer, but in my test it didn’t work, remembering that I did the SQL query test in HeidiSQL.

after validating in HeidiSQL I added in PHPRad Classic, and nothing.

What am I doing wrong?

@snarthost it should work. But make sure Authentication have been setup, else it will not contain any ID.

I managed to solve the problem. my question is that my user id is just id, as my login is based on the user id, i managed to solve

Before: $query_params[‘uid’] = auth()->user()->user_id;

Current: $query_params[‘uid’] = auth()->user()->id;