Answer the question
In order to leave comments, you need to log in
How to use foreign database keys on a website?
There are two tables in the database: users and area, in users there are user data, and in area - the names of the districts.
Foreign keys are set up as users.area_id = area.area_id, everything works well in phpmyadmin itself.
On the site I load both tables like this:
$users= DB::select('select * from users');
$areas = DB::select('select * from area');
{{ $areas[$users->area_id]->name }}
{{ $users->area_id->name }}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question