Teşekkürler
Peki konudan ayrı bir soru sorayım.
İki tablom var carts ve products diye bunları Cart modelinde
public function product(){
return $this->hasMany('App\Product',"id","product_id");
}
şeklinde ilişkilendirdim ve aşağıdaki kodla kişinin o andaki sepetinde bulunan ürünleri listeledim toplam 7 obje döndürmesi lazım
$data=Cart::with("product")->where('session_id',$key)->get();
print_r($data);
return view('cart',compact('data'));
ama print_r yapınca neredeyse 1000 satırlık bir dizi gönderiyormuş view'e.
Bu aşırı bir yük getirmezmi sizce
Illuminate\Database\Eloquent\Collection Object ( [items:protected] => Array ( [0] => App\Cart Object ( [connection:protected] => [table:protected] => [primaryKey:protected] => id [keyType:protected] => int [perPage:protected] => 15 [incrementing] => 1 [timestamps] => 1 [attributes:protected] => Array ( [id] => 4 [created_at] => 2018-04-12 16:23:51 [updated_at] => 2018-04-12 16:23:51 [session_id] => 0ctIOzR3xYue1y8Uqn5nRBwbPWksn3jmN9rTK7rEu6I5X [product_id] => 1 [quantity] => 1 ) [original:protected] => Array ( [id] => 4 [created_at] => 2018-04-12 16:23:51 [updated_at] => 2018-04-12 16:23:51 [session_id] => 0ctIOzR3xYue1y8Uqn5nRBwbPWksn3jmN9rTK7rEu6I5X [product_id] => 1 [quantity] => 1 ) [relations:protected] => Array ( [product] => Illuminate\Database\Eloquent\Collection Object ( [items:protected] => Array ( [0] => App\Product Object ( [connection:protected] => [table:protected] => [primaryKey:protected] => id [keyType:protected] => int [perPage:protected] => 15 [incrementing] => 1 [timestamps] => 1 [attributes:protected] => Array ( [id] => 1 [name] => Satış Takip Sistemi [description] => Bu yazılımla işyerinizdeki satışları takip edebilir, raporları tutabilirsiniz [price] => 600 [category_id] => 1 [created_at] => 2018-04-10 14:31:39 [updated_at] => 2018-04-10 14:31:39 ) [original:protected] => Array ( [id] => 1 [name] => Satış Takip Sistemi [description] => Bu yazılımla işyerinizdeki satışları takip edebilir, raporları tutabilirsiniz [price] => 600 [category_id] => 1 [created_at] => 2018-04-10 14:31:39 [updated_at] => 2018-04-10 14:31:39 ) [relations:protected] => Array ( ) [hidden:protected] => Array ( ) [visible:protected] => Array ( ) [appends:protected] => Array ( ) [fillable:protected] => Array ( ) [guarded:protected] => Array ( [0] => * ) [dates:protected] => Array ( ) [dateFormat:protected] => [casts:protected] => Array ( ) [touches:protected] => Array ( ) [observables:protected] => Array ( ) [with:protected] => Array ( ) [morphClass:protected] => [exists] => 1 [wasRecentlyCreated] => ) ) ) ) [hidden:protected] => Array ( ) [visible:protected] => Array ( ) [appends:protected] => Array ( ) [fillable:protected] => Array ( ) [guarded:protected] => Array ( [0] => * ) [dates:protected] => Array ( ) [dateFormat:protected] => [casts:protected] => Array ( ) [touches:protected] => Array ( ) [observables:protected] => Array ( ) [with:protected] => Array ( ) [morphClass:protected] => [exists] => 1 [wasRecentlyCreated] => ) [1] => App\Cart Object ( [connection:protected] => [table:protected] => [primaryKey:protected] => id [keyType:protected] => int [perPage:protected] => 15 [incrementing] => 1 [timestamps] => 1 [attributes:protected] => Array ( [id] => 5 [created_at] => 2018-04-12 16:26:26 [updated_at] => 2018-04-12 16:26:26 [session_id] => 0ctIOzR3xYue1y8Uqn5nRBwbPWksn3jmN9rTK7rEu6I5X [product_id] => 1 [quantity] => 1 ) [original:protected] => Array ( [id] => 5 [created_at] => 2018-04-12 16:26:26 [updated_at] => 2018-04-12 16:26:26 [session_id] => 0ctIOzR3xYue1y8Uqn5nRBwbPWksn3jmN9rTK7rEu6I5X [product_id] => 1 [quantity] => 1 ) [relations:protected] => Array ( [product] => Illuminate\Database\Eloquent\Collection Object ( [items:protected] => Array ( [0] => App\Product Object ( [connection:protected] => [table:protected] => [primaryKey:protected] => id [keyType:protected] => int [perPage:protected] => 15 [incrementing] => 1 [timestamps] => 1 [attributes:protected] => Array ( [id] => 1 [name] => Satış Takip Sistemi [description] => Bu yazılımla işyerinizdeki satışları takip edebilir, raporları tutabilirsiniz [price] => 600 [category_id] => 1 [created_at] => 2018-04-10 14:31:39 [updated_at] => 2018-04-10 14:31:39 ) [original:protected] => Array ( [id] => 1 [name] => Satış Takip Sistemi [description] => Bu yazılımla işyerinizdeki satışları takip edebilir, raporları tutabilirsiniz [price] => 600 [category_id] => 1 [created_at] => 2018-04-10 14:31:39 [updated_at] => 2018-04-10 14:31:39 ) [relations:protected] => Array ( ) [hidden:protected] => Array ( ) [visible:protected] => Array ( ) [appends:protected] => Array ( ) [fillable:protected] => Array ( ) [guarded:protected] => Array ( [0] => * ) [dates:protected] => Array ( ) [dateFormat:protected] => [casts:protected] => Array ( ) [touches:protected] => Array ( ) [observables:protected] => Array ( ) [with:protected] => Array ( ) [morphClass:protected] => [exists] => 1 [wasRecentlyCreated] => ) ) ) ) [hidden:protected] => Array ( ) [visible:protected] => Array ( ) [appends:protected] => Array ( ) [fillable:protected] => Array ( ) [guarded:protected] => Array ( [0] => * ) [dates:protected] => Array ( ) [dateFormat:protected] => [casts:protected] => Array ( ) [touches:protected] => Array ( ) [observables:protected] => Array ( ) [with:protected] => Array ( ) [morphClass:protected] => [exists] => 1 [wasRecentlyCreated] => ) [2] => App\Cart Object ( [connection:protected] => [table:protected] => [primaryKey:protected] => id [keyType:protected] => int [perPage:protected] => 15 [incrementing] => 1 [timestamps] => 1 [attributes:protected] => Array ( [id] => 6 [created_at] => 2018-04-12 16:51:33 [updated_at] => 2018-04-12 16:51:33 [session_id] => 0ctIOzR3xYue1y8Uqn5nRBwbPWksn3jmN9rTK7rEu6I5X [product_id] => 1 [quantity] => 1 ) [original:protected] => Array ( [id] => 6 [created_at] => 2018-04-12 16:51:33 [updated_at] => 2018-04-12 16:51:33 [session_id] => 0ctIOzR3xYue1y8Uqn5nRBwbPWksn3jmN9rTK7rEu6I5X [product_id] => 1 [quantity] => 1 ) [relations:protected] => Array ( [product] => Illuminate\Database\Eloquent\Collection Object ( [items:protected] => Array ( [0] => App\Product Object ( [connection:protected] => [table:protected] => [primaryKey:protected] => id [keyType:protected] => int [perPage:protected] => 15 [incrementing] => 1 [timestamps] => 1 [attributes:protected] => Array ( [id] => 1 [name] => Satış Takip Sistemi [description] => Bu yazılımla işyerinizdeki satışları takip edebilir, raporları tutabilirsiniz [price] => 600 [category_id] => 1 [created_at] => 2018-04-10 14:31:39 [updated_at] => 2018-04-10 14:31:39 ) [original:protected] => Array ( [id] => 1 [name] => Satış Takip Sistemi [description] => Bu yazılımla işyerinizdeki satışları takip edebilir, raporları tutabilirsiniz [price] => 600 [category_id] => 1 [created_at] => 2018-04-10 14:31:39 [updated_at] => 2018-04-10 14:31:39 ) [relations:protected] => Array ( ) [hidden:protected] => Array ( ) [visible:protected] => Array ( ) [appends:protected] => Array ( ) [fillable:protected] => Array ( ) [guarded:protected] => Array ( [0] => * ) [dates:protected] => Array ( ) [dateFormat:protected] => [casts:protected] => Array ( ) [touches:protected] => Array ( ) [observables:protected] => Array ( ) [with:protected] => Array ( ) [morphClass:protected] => [exists] => 1 [wasRecentlyCreated] => ) ) ) ) [hidden:protected] => Array ( ) [visible:protected] => Array ( ) [appends:protected] => Array ( ) [fillable:protected] => Array ( ) [guarded:protected] => Array ( [0] => * ) [dates:protected] => Array ( ) [dateFormat:protected] => [casts:protected] => Array ( ) [touches:protected] => Array ( ) [observables:protected] => Array ( ) [with:protected] => Array ( ) [morphClass:protected] => [exists] => 1 [wasRecentlyCreated] => ) [3] => App\Cart Object ( [connection:protected] => [table:protected] => [primaryKey:protected] => id [keyType:protected] => int [perPage:protected] => 15 [incrementing] => 1 [timestamps] => 1 [attributes:protected] => Array ( [id] => 7 [created_at] => 2018-04-12 17:47:32 [updated_at] => 2018-04-12 17:47:32 [session_id] => 0ctIOzR3xYue1y8Uqn5nRBwbPWksn3jmN9rTK7rEu6I5X [product_id] => 2 [quantity] => 1 ) [original:protected] => Array ( [id] => 7 [created_at] => 2018-04-12 17:47:32 [updated_at] => 2018-04-12 17:47:32 [session_id] => 0ctIOzR3xYue1y8Uqn5nRBwbPWksn3jmN9rTK7rEu6I5X [product_id] => 2 [quantity] => 1 ) [relations:protected] => Array ( [product] => Illuminate\Database\Eloquent\Collection Object ( [items:protected] => Array ( [0] => App\Product Object ( [connection:protected] => [table:protected] => [primaryKey:protected] => id [keyType:protected] => int [perPage:protected] => 15 [incrementing] => 1 [timestamps] => 1 [attributes:protected] => Array ( [id] => 2 [name] => Barkod Sistemi [description] => Bu yazılımla işyerinizdeki satışları takip edebilir, raporları tutabilirsiniz [price] => 250 [category_id] => 2 [created_at] => 2018-04-10 14:31:39 [updated_at] => 2018-04-10 14:31:39 ) [original:protected] => Array ( [id] => 2 [name] => Barkod Sistemi [description] => Bu yazılımla işyerinizdeki satışları takip edebilir, raporları tutabilirsiniz [price] => 250 [category_id] => 2 [created_at] => 2018-04-10 14:31:39 [updated_at] => 2018-04-10 14:31:39 ) [relations:protected] => Array ( ) [hidden:protected] => Array ( ) [visible:protected] => Array ( ) [appends:protected] => Array ( ) [fillable:protected] => Array ( ) [guarded:protected] => Array ( [0] => * ) [dates:protected] => Array ( ) [dateFormat:protected] => [casts:protected] => Array ( ) [touches:protected] => Array ( ) [observables:protected] => Array ( ) [with:protected] => Array ( ) [morphClass:protected] => [exists] => 1 [wasRecentlyCreated] => ) ) ) ) [hidden:protected] => Array ( ) [visible:protected] => Array ( ) [appends:protected] => Array ( ) [fillable:protected] => Array ( ) [guarded:protected] => Array ( [0] => * ) [dates:protected] => Array ( ) [dateFormat:protected] => [casts:protected] => Array ( ) [touches:protected] => Array ( ) [observables:protected] => Array ( ) [with:protected] => Array ( ) [morphClass:protected] => [exists] => 1 [wasRecentlyCreated] => ) [4] => App\Cart Object ( [connection:protected] => [table:protected] => [primaryKey:protected] => id [keyType:protected] => int [perPage:protected] => 15 [incrementing] => 1 [timestamps] => 1 [attributes:protected] => Array ( [id] => 8 [created_at] => 2018-04-12 17:48:33 [updated_at] => 2018-04-12 17:48:33 [session_id] => 0ctIOzR3xYue1y8Uqn5nRBwbPWksn3jmN9rTK7rEu6I5X [product_id] => 2 [quantity] => 1 ) [original:protected] => Array ( [id] => 8 [created_at] => 2018-04-12 17:48:33 [updated_at] => 2018-04-12 17:48:33 [session_id] => 0ctIOzR3xYue1y8Uqn5nRBwbPWksn3jmN9rTK7rEu6I5X [product_id] => 2 [quantity] => 1 ) [relations:protected] => Array ( [product] => Illuminate\Database\Eloquent\Collection Object ( [items:protected] => Array ( [0] => App\Product Object ( [connection:protected] => [table:protected] => [primaryKey:protected] => id [keyType:protected] => int [perPage:protected] => 15 [incrementing] => 1 [timestamps] => 1 [attributes:protected] => Array ( [id] => 2 [name] => Barkod Sistemi [description] => Bu yazılımla işyerinizdeki satışları takip edebilir, raporları tutabilirsiniz [price] => 250 [category_id] => 2 [created_at] => 2018-04-10 14:31:39 [updated_at] => 2018-04-10 14:31:39 ) [original:protected] => Array ( [id] => 2 [name] => Barkod Sistemi [description] => Bu yazılımla işyerinizdeki satışları takip edebilir, raporları tutabilirsiniz [price] => 250 [category_id] => 2 [created_at] => 2018-04-10 14:31:39 [updated_at] => 2018-04-10 14:31:39 ) [relations:protected] => Array ( ) [hidden:protected] => Array ( ) [visible:protected] => Array ( ) [appends:protected] => Array ( ) [fillable:protected] => Array ( ) [guarded:protected] => Array ( [0] => * ) [dates:protected] => Array ( ) [dateFormat:protected] => [casts:protected] => Array ( ) [touches:protected] => Array ( ) [observables:protected] => Array ( ) [with:protected] => Array ( ) [morphClass:protected] => [exists] => 1 [wasRecentlyCreated] => ) ) ) ) [hidden:protected] => Array ( ) [visible:protected] => Array ( ) [appends:protected] => Array ( ) [fillable:protected] => Array ( ) [guarded:protected] => Array ( [0] => * ) [dates:protected] => Array ( ) [dateFormat:protected] => [casts:protected] => Array ( ) [touches:protected] => Array ( ) [observables:protected] => Array ( ) [with:protected] => Array ( ) [morphClass:protected] => [exists] => 1 [wasRecentlyCreated] => ) [5] => App\Cart Object ( [connection:protected] => [table:protected] => [primaryKey:protected] => id [keyType:protected] => int [perPage:protected] => 15 [incrementing] => 1 [timestamps] => 1 [attributes:protected] => Array ( [id] => 9 [created_at] => 2018-04-12 17:51:26 [updated_at] => 2018-04-12 17:51:26 [session_id] => 0ctIOzR3xYue1y8Uqn5nRBwbPWksn3jmN9rTK7rEu6I5X [product_id] => 3 [quantity] => 1 ) [original:protected] => Array ( [id] => 9 [created_at] => 2018-04-12 17:51:26 [updated_at] => 2018-04-12 17:51:26 [session_id] => 0ctIOzR3xYue1y8Uqn5nRBwbPWksn3jmN9rTK7rEu6I5X [product_id] => 3 [quantity] => 1 ) [relations:protected] => Array ( [product] => Illuminate\Database\Eloquent\Collection Object ( [items:protected] => Array ( [0] => App\Product Object ( [connection:protected] => [table:protected] => [primaryKey:protected] => id [keyType:protected] => int [perPage:protected] => 15 [incrementing] => 1 [timestamps] => 1 [attributes:protected] => Array ( [id] => 3 [name] => Android Online oyun [description] => Bu yazılımla işyerinizdeki satışları takip edebilir, raporları tutabilirsiniz [price] => 2.9 [category_id] => 3 [created_at] => 2018-04-10 14:31:39 [updated_at] => 2018-04-10 14:31:39 ) [original:protected] => Array ( [id] => 3 [name] => Android Online oyun [description] => Bu yazılımla işyerinizdeki satışları takip edebilir, raporları tutabilirsiniz [price] => 2.9 [category_id] => 3 [created_at] => 2018-04-10 14:31:39 [updated_at] => 2018-04-10 14:31:39 ) [relations:protected] => Array ( ) [hidden:protected] => Array ( ) [visible:protected] => Array ( ) [appends:protected] => Array ( ) [fillable:protected] => Array ( ) [guarded:protected] => Array ( [0] => * ) [dates:protected] => Array ( ) [dateFormat:protected] => [casts:protected] => Array ( ) [touches:protected] => Array ( ) [observables:protected] => Array ( ) [with:protected] => Array ( ) [morphClass:protected] => [exists] => 1 [wasRecentlyCreated] => ) ) ) ) [hidden:protected] => Array ( ) [visible:protected] => Array ( ) [appends:protected] => Array ( ) [fillable:protected] => Array ( ) [guarded:protected] => Array ( [0] => * ) [dates:protected] => Array ( ) [dateFormat:protected] => [casts:protected] => Array ( ) [touches:protected] => Array ( ) [observables:protected] => Array ( ) [with:protected] => Array ( ) [morphClass:protected] => [exists] => 1 [wasRecentlyCreated] => ) ) )