There are two packages tables and packages_description. In the first title, the price. In another package_id, a description. Wrote a request for the withdrawal of packages and their descriptions. Issued:
[items:protected] => Array ( [0] => stdClass Object ( [id] => 7 [title] => Старт [price] => 500 [order] => 1 [addition] => [description] => 1 вариант рекламного объявления ) [1] => stdClass Object ( [id] => 7 [title] => Старт [price] => 500 [order] => 1 [addition] => [description] => Запуск 1 рекламного объявления ) [2] => stdClass Object ( [id] => 7 [title] => Старт [price] => 500 [order] => 1 [addition] => [description] => отчет ) [3] => stdClass Object ( [id] => 8 [title] => Бизнес [price] => 1500 [order] => 2 [addition] => [description] => отчет ) [4] => stdClass Object ( [id] => 9 [title] => Индивидуальный [price] => 5000 [order] => 3 [addition] => от [description] => ) ) The request itself:
$packages = DB::table('packages') ->select(DB::raw('packages.*, packages_description.description as description')) ->leftJoin('packages_description', 'packages.id', '=', 'packages_description.package_id') ->groupBy('id', 'description') ->get(); How to display:
( [id] => 7 [title] => Старт [price] => 500 [order] => 1 [addition] => [description] => array( '1 вариант рекламного объявления', 'Запуск 1 рекламного объявления', 'отчет') ) How to write a request?