Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function orders(){
- return $this->hasMany(Order::class);
- }
- public function user(){
- return $this->belongsTo(User::class);
- }
- public function product(){
- return $this->belongsTo(Product::class);
- }
- {
- id: 11,
- quantity: 2,
- customer: {
- id: 6,
- name: "saging",
- email: "saging@gmail.com",
- role_id: 3,
- },
- items: {
- id: 7,
- name: "Pellentesque semper",
- description: "raesent sit amet elementum purus. ",
- price: "72.21",
- cover_image: "7CPVS7yjqba9iJ7J.jpg",
- }
- },
- {
- id: 12,
- quantity: 2,
- customer: {
- id: 6,
- name: "saging",
- email: "saging@gmail.com",
- role_id: 3,
- },
- items: {
- id: 3,
- name: "Donec nec mattis ligula",
- description: "Pellentesque semper, augue at aliquet tincidunt",
- price: "33.21",
- cover_image: "ZJbbzjPwDXrcbkwi.jpg",
- }
- }
- $products = Order::with('user','product');
- return OrdersResource::collection($products->paginate(5));
- {
- id: 12,
- quantity: 2,
- customer: {
- id: 6,
- name: "saging",
- email: "saging@gmail.com",
- role_id: 3,
- },
- items: [
- {
- id: 3,
- name: "Donec nec mattis ligula",
- description: "Pellentesque semper, augue at aliquet tincidunt",
- price: "33.21",
- cover_image: "ZJbbzjPwDXrcbkwi.jpg",
- },
- {
- id: 7,
- name: "Pellentesque semper",
- description: "raesent sit amet elementum purus. ",
- price: "72.21",
- cover_image: "7CPVS7yjqba9iJ7J.jpg",
- }
- ]
- }
Add Comment
Please, Sign In to add comment