mirror of
https://github.com/kevin-DL/scraps.git
synced 2026-01-12 02:05:14 +00:00
Do the search
This commit is contained in:
13
app/Http/Controllers/DashboardController.php
Normal file
13
app/Http/Controllers/DashboardController.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Inertia\Inertia;
|
||||
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return Inertia::render('Dashboard');
|
||||
}
|
||||
}
|
||||
28
app/Http/Controllers/SearchController.php
Normal file
28
app/Http/Controllers/SearchController.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Integrations\Spoonacular\Requests\FindRecipesByIngredients;
|
||||
use App\Http\Integrations\Spoonacular\SpoonacularConnector;
|
||||
use App\Http\Requests\RecipeSearchRequest;
|
||||
use Inertia\Inertia;
|
||||
|
||||
class SearchController extends Controller
|
||||
{
|
||||
public function recipes(RecipeSearchRequest $request)
|
||||
{
|
||||
$data = $request->validated();
|
||||
$connector = new SpoonacularConnector();
|
||||
$request = new FindRecipesByIngredients(
|
||||
ingredients: array_map("trim", explode(",", $data['ingredients'])),
|
||||
ranking: 2
|
||||
);
|
||||
|
||||
$response = $connector->send($request);
|
||||
|
||||
return Inertia::render('Search/Recipes', [
|
||||
'recipes' => $response->json(),
|
||||
'previousSearch' => $data['ingredients']
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user