Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save victorhugorch/2ed05766de5fd0481efac09fcd91e20e to your computer and use it in GitHub Desktop.
Save victorhugorch/2ed05766de5fd0481efac09fcd91e20e to your computer and use it in GitHub Desktop.
<?php
namespace App\Http\Controllers;
use Illuminate\Http\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
class ProductsController extends Controller
{
public function index(ProductRepositoryInterface $product) : JsonResponse
{
return response()->json([
'data' => $product->mostRecent(Carbon::yesterday())
], Response::HTTP_OK);
}
}
interface ProductRepositoryInterface
{
public function mostRecent(Carbon $date) : Collection
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment