34 lines
713 B
PHP
34 lines
713 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Data\ItemsCollection;
|
|
use Illuminate\Http\Request;
|
|
|
|
class ItemController extends Controller
|
|
{
|
|
/**
|
|
* @var ItemsCollection
|
|
*/
|
|
private ItemsCollection $itemsCollection;
|
|
|
|
public function __construct(ItemsCollection $itemsCollection)
|
|
{
|
|
$this->itemsCollection = $itemsCollection;
|
|
}
|
|
|
|
public function search(Request $request)
|
|
{
|
|
return response()->json([
|
|
'item' => $this->itemsCollection->findItem($request->input('query')),
|
|
]);
|
|
}
|
|
|
|
public function getItem(string $id)
|
|
{
|
|
return response()->json([
|
|
'item' => $this->itemsCollection->getItemById($id),
|
|
]);
|
|
}
|
|
}
|