How do I return the following response format using the code below:
{"data":[],"meta":{"paging":{"links":[],"total":0},"time":0.079}}
The controller code:
public function someMethod()
{
$var=SomeModel::with(['status' => function ($query) {
$query->where('name', 'like', '%Pending Payment%');
}])->get();
return [
'data' => $var,
];
}
Response am getting
{"data":[]}
2
Answers
I was able to solve the problem using Resource Collection