Вот мой код в контроллере и вывод, но я хочу, чтобы этот порядок не был нулевым.
$ordered_products = Product::with('order')->get();
Выход:
[
{
"id":1,
"breed_id":1,
"weight":"70",
"price":"49000",
"quantity":1,
"no_of_sold_out_items":0,
"image":"sojat11561700682.jpg",
"description":"Sojat is a breed of Bakra. This bakra can be used for Bakri Eid, Eid, Sadqa, Aqeeqa etc.",
"status":1,
"created_at":"2019-06-28 05:44:43",
"updated_at":"2019-06-28 05:44:43",
"deleted_at":null,
"order":null
},
{
"id":2,
"breed_id":1,
"weight":"70",
"price":"49000",
"quantity":1,
"no_of_sold_out_items":0,
"image":"sojat21561700788.jpg",
"description":"Sojat is a breed of Bakra. This bakra can be used for Bakri Eid, Eid, Sadqa, Aqeeqa etc.",
"status":1,
"created_at":"2019-06-28 05:46:28",
"updated_at":"2019-06-28 05:46:28",
"deleted_at":null,
"order":null
},
{
"id":3,
"breed_id":1,
"weight":"70",
"price":"49000",
"quantity":1,
"no_of_sold_out_items":0,
"image":"sojat31561700834.jpg",
"description":"Sojat is a breed of Bakra. This bakra can be used for Bakri Eid, Eid, Sadqa, Aqeeqa etc.",
"status":1,
"created_at":"2019-06-28 05:47:14",
"updated_at":"2019-06-28 05:47:14",
"deleted_at":null,
"order":null
},
{
"id":4,
"breed_id":2,
"weight":"35",
"price":"17000",
"quantity":1,
"no_of_sold_out_items":0,
"image":"sirohi11561701212.jpg",
"description":"Rirohi Desi is type of breed of bakra. This Bakra can be used for Eid, Bakri Eid, Sadqa, Aqeeqa etc.",
"status":1,
"created_at":"2019-06-28 05:53:32",
"updated_at":"2019-06-28 05:53:32",
"deleted_at":null,
"order":null
},
{
"id":5,
"breed_id":3,
"weight":"50",
"price":"25000",
"quantity":0,
"no_of_sold_out_items":1,
"image":"barbara11561701251.jpg",
"description":"Barbara is type of breed of bakra. This Bakra can be used for Eid, Bakri Eid, Sadqa, Aqeeqa etc.",
"status":1,
"created_at":"2019-06-28 05:54:11",
"updated_at":"2019-06-28 10:56:47",
"deleted_at":null,
"order":{
"id":2,
"product_id":5,
"user_id":2,
"quantity":1,
"status":"processed",
"created_at":"2019-06-28 10:56:47",
"updated_at":"2019-06-28 10:56:47",
"deleted_at":null
}
},
{
"id":6,
"breed_id":4,
"weight":"32",
"price":"15200",
"quantity":1,
"no_of_sold_out_items":0,
"image":"desi11561701294.jpg",
"description":"Desi is type of breed of bakra. This Bakra can be used for Eid, Bakri Eid, Sadqa, Aqeeqa etc.",
"status":1,
"created_at":"2019-06-28 05:54:54",
"updated_at":"2019-06-28 05:54:54",
"deleted_at":null,
"order":null
},
{
"id":7,
"breed_id":5,
"weight":"100",
"price":"70000",
"quantity":0,
"no_of_sold_out_items":1,
"image":"tota pari alwar11561701353.jpg",
"description":"Tota - Pari Alwar is type of breed of bakra. This Bakra can be used for Eid, Bakri Eid, Sadqa, Aqeeqa etc.",
"status":1,
"created_at":"2019-06-28 05:55:53",
"updated_at":"2019-06-28 07:29:34",
"deleted_at":null,
"order":{
"id":1,
"product_id":7,
"user_id":2,
"quantity":1,
"status":"processed",
"created_at":"2019-06-28 07:29:33",
"updated_at":"2019-06-28 07:29:33",
"deleted_at":null
}
}
]