Use MicroKernelTrait to bootstrap application. Rewrote routes, controllers and structure of application a bit. Including use of twig.
This commit is contained in:
@@ -3,15 +3,21 @@
|
||||
namespace Krzysiej\RyobiCrawler\Controller;
|
||||
|
||||
use Krzysiej\RyobiCrawler\Models\Product;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
final class SearchController extends BaseController
|
||||
{
|
||||
public function __invoke(string $search): void
|
||||
#[Route('/search', name: 'app_search')]
|
||||
public function __invoke(Request $request): Response
|
||||
{
|
||||
$search = $request->query->get('search');
|
||||
//dd();
|
||||
$products = Product::with('price')
|
||||
->orWhere([['name', 'like', "%$search%"]])
|
||||
->orWhere([['subTitle', 'like', "%$search%"]])->get();
|
||||
|
||||
$this->twig->display('productList.html.twig', ['products' => $products ?? [], 'search' => $search]);
|
||||
return $this->render('productList.html.twig', ['products' => $products ?? [], 'search' => $search]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user