Inside the relative database there are two corresponding tables.

- Названия категорий - Списки категорий 

The output is carried out through the "cattle code"

 $cat_name = DB::table('cat_name')->get(); foreach($cat_name as $row) { $child = DB::table('categories')->where('id','=',$row->id)->get(); echo $row->title; foreach($child as $c) { echo $c->title; } } 

Is it possible to solve the problem of relativity within the controller alone?

  • What is the reason for the request to solve the problem within the controller? Why not formulate a regular query with JOINs? Then transfer it to Eloquent. I think your problem can be solved by a single query. - VenZell
  • Can you demonstrate an example? Thank you. - asd
  • An example based on what? You did not specify the structure of your tables. - VenZell
  • For example, here's how to translate this query into Eloquent "SELECT * FROM categories JOIN categories_parent ON categories.parent_id = categories.id"? - asd
  • DB::table('categories')->leftJoin('categories_parent', 'categories.parent_id', '=', 'categories.id') - VenZell

0