Следующая строка возвращает все записи из двух таблиц, потому что я добавил отношение для этих двух таблиц.
$allmarketers = ProductStock::whereRaw('MONTH(created_at) = ?',[$currentMonth])->get();
Теперь я хочу провести l oop через записи в представлении и отобразить записи из двух таблиц для каждого пользователя. Я забыл, как этого добиться.
Я пытался
@foreach($allmarketers as $item)
Но как мне получить значения обеих таблиц внутри этого l oop?
Var_dump
n)#601 (1) { ["items":protected]=> array(3) { [0]=> object(App\ProductStock)#602 (26) { ["table":protected]=> string(14) "product_stocks" ["fillable":protected]=> array(5) { [0]=> string(8) "marketer" [1]=> string(6) "target" [2]=> string(6) "_token" [3]=> string(10) "updated_at" [4]=> string(10) "created_at" } ["connection":protected]=> string(5) "mysql" ["primaryKey":protected]=> string(2) "id" ["keyType":protected]=> string(3) "int" ["incrementing"]=> bool(true) ["with":protected]=> array(0) { } ["withCount":protected]=> array(0) { } ["perPage":protected]=> int(15) ["exists"]=> bool(true) ["wasRecentlyCreated"]=> bool(false) ["attributes":protected]=> array(9) { ["id"]=> int(97) ["user_id"]=> int(70) ["marketer"]=> string(18) "Samson Samson | 70" ["target"]=> string(3) "100" ["_token"]=> NULL ["status"]=> int(1) ["vehicle"]=> string(10) "Unassigned" ["created_at"]=> string(19) "2020-01-07 13:11:47" ["updated_at"]=> string(19) "2020-01-07 13:11:47" } ["original":protected]=> array(9) { ["id"]=> int(97) ["user_id"]=> int(70) ["marketer"]=> string(18) "Samson Samson | 70" ["target"]=> string(3) "100" ["_token"]=> NULL ["status"]=> int(1) ["vehicle"]=> string(10) "Unassigned" ["created_at"]=> string(19) "2020-01-07 13:11:47" ["updated_at"]=> string(19) "2020-01-07 13:11:47" } ["changes":protected]=> array(0) { } ["casts":protected]=> array(0) { } ["dates":protected]=> array(0) { } ["dateFormat":protected]=> NULL ["appends":protected]=> array(0) { } ["dispatchesEvents":protected]=> array(0) { } ["observables":protected]=> array(0) { } ["relations":protected]=> array(0) { } ["touches":protected]=> array(0) { } ["timestamps"]=> bool(true) ["hidden":protected]=> array(0) { } ["visible":protected]=> array(0) { } ["guarded":protected]=> array(1) { [0]=> string(1) "*" } } [1]=> object(App\ProductStock)#603 (26) { ["table":protected]=> string(14) "product_stocks" ["fillable":protected]=> array(5) { [0]=> string(8) "marketer" [1]=> string(6) "target" [2]=> string(6) "_token" [3]=> string(10) "updated_at" [4]=> string(10) "created_at" } ["connection":protected]=> string(5) "mysql" ["primaryKey":protected]=> string(2) "id" ["keyType":protected]=> string(3) "int" ["incrementing"]=> bool(true) ["with":protected]=> array(0) { } ["withCount":protected]=> array(0) { } ["perPage":protected]=> int(15) ["exists"]=> bool(true) ["wasRecentlyCreated"]=> bool(false) ["attributes":protected]=> array(9) { ["id"]=> int(98) ["user_id"]=> int(72) ["marketer"]=> string(22) "Emmanuel Increase | 72" ["target"]=> string(3) "150" ["_token"]=> NULL ["status"]=> int(1) ["vehicle"]=> string(10) "Unassigned" ["created_at"]=> string(19) "2020-01-07 13:11:47" ["updated_at"]=> string(19) "2020-01-07 13:11:47" } ["original":protected]=> array(9) { ["id"]=> int(98) ["user_id"]=> int(72) ["marketer"]=> string(22) "Emmanuel Increase | 72" ["target"]=> string(3) "150" ["_token"]=> NULL ["status"]=> int(1) ["vehicle"]=> string(10) "Unassigned" ["created_at"]=> string(19) "2020-01-07 13:11:47" ["updated_at"]=> string(19) "2020-01-07 13:11:47" } ["changes":protected]=> array(0) { } ["casts":protected]=> array(0) { } ["dates":protected]=> array(0) { } ["dateFormat":protected]=> NULL ["appends":protected]=> array(0) { } ["dispatchesEvents":protected]=> array(0) { } ["observables":protected]=> array(0) { } ["relations":protected]=> array(0) { } ["touches":protected]=> array(0) { } ["timestamps"]=> bool(true) ["hidden":protected]=> array(0) { } ["visible":protected]=> array(0) { } ["guarded":protected]=> array(1) { [0]=> string(1) "*" } } [2]=> object(App\ProductStock)#604 (26) { ["table":protected]=> string(14) "product_stocks" ["fillable":protected]=> array(5) { [0]=> string(8) "marketer" [1]=> string(6) "target" [2]=> string(6) "_token" [3]=> string(10) "updated_at" [4]=> string(10) "created_at" } ["connection":protected]=> string(5) "mysql" ["primaryKey":protected]=> string(2) "id" ["keyType":protected]=> string(3) "int" ["incrementing"]=> bool(true) ["with":protected]=> array(0) { } ["withCount":protected]=> array(0) { } ["perPage":protected]=> int(15) ["exists"]=> bool(true) ["wasRecentlyCreated"]=> bool(false) ["attributes":protected]=> array(9) { ["id"]=> int(99) ["user_id"]=> int(73) ["marketer"]=> string(18) "Timothy Kukah | 73" ["target"]=> string(3) "200" ["_token"]=> NULL ["status"]=> int(1) ["vehicle"]=> string(10) "Unassigned" ["created_at"]=> string(19) "2020-01-07 13:11:47" ["updated_at"]=> string(19) "2020-01-07 13:11:47" } ["original":protected]=> array(9) { ["id"]=> int(99) ["user_id"]=> int(73) ["marketer"]=> string(18) "Timothy Kukah | 73" ["target"]=> string(3) "200" ["_token"]=> NULL ["status"]=> int(1) ["vehicle"]=> string(10) "Unassigned" ["created_at"]=> string(19) "2020-01-07 13:11:47" ["updated_at"]=> string(19) "2020-01-07 13:11:47" } ["changes":protected]=> array(0) { } ["casts":protected]=> array(0) { } ["dates":protected]=> array(0) { } ["dateFormat":protected]=> NULL ["appends":protected]=> array(0) { } ["dispatchesEvents":protected]=> array(0) { } ["observables":protected]=> array(0) { } ["relations":protected]=> array(0) { } ["touches":protected]=> array(0) { } ["timestamps"]=> bool(true) ["hidden":protected]=> array(0) { } ["visible":protected]=> array(0) { } ["guarded":protected]=> array(1) { [0]=> string(1) "*" } } } }