I'm building an application and I need to get result from three tables, Applications
, Companies
, Sectors
. In Applications
table I have a json_encoded array saved for sectors like ["25", "10", "8", "39"]
.
I'm using joins to get values from related tables but I cannot get sectors based on that array.
Any ideas on how to get this working ? Thank you!
Here is my controller query:
$data = DB::table( 'applications' )
->join( 'companies', 'applications.company_id', '=', 'companies.id' )
->join( 'states', 'applications.state_id', '=', 'states.id' )
->join( 'cities', 'applications.city_id', '=', 'cities.id' )
/* ->join('sectors', 'applications.sectors', 'IN', 'sectors.id') */
->select('applications.*', 'companies.company_name as company_name', 'states.name as state_name', 'cities.city as city_name')
->orderBy('applications.id', 'asc')
->get();