restore composer.json, add mysqli extension
This commit is contained in:
31
app/Http/Controllers/API/CompilationController.php
Executable file
31
app/Http/Controllers/API/CompilationController.php
Executable file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\CompilationResource;
|
||||
use App\Http\Resources\ProductPaginationResource;
|
||||
use App\Models\Compilation;
|
||||
use App\Models\Currency;
|
||||
|
||||
class CompilationController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$compilations = Compilation::where('published', 1)->get();
|
||||
|
||||
$currency = Currency::latest()->first();
|
||||
// add currency to cache
|
||||
cache()->put('currency', $currency, now()->addMinutes(60));
|
||||
|
||||
return CompilationResource::collection($compilations);
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$compilation = Compilation::findOrFail($id);
|
||||
$products = $compilation->products()->paginate($request->limit ?? 10);
|
||||
|
||||
return (new ProductPaginationResource($products));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user