/** * Display a listing of the resource. * * @param Request $request * @param int $cardNumber * * @return Response */ public function index(Request $request, $cardNumber) { $fromDate = $request->input('from_date', 10); $card = Card::with(['balances' => function ($query) use($fromDate) { $query->where('created_at', '>=', Carbon::now()->subDays($fromDate)); }])->where('number', $cardNumber)->first(); if (!$card) { return $this->respondNotFound(); } return $this->respond(fractal()->collection($card->balances, new BalanceTransformer())->toArray()); }