diff --git a/app/Http/Controllers/MainPageController.php b/app/Http/Controllers/MainPageController.php index 0ab9064..46ad2a3 100644 --- a/app/Http/Controllers/MainPageController.php +++ b/app/Http/Controllers/MainPageController.php @@ -7,9 +7,15 @@ use Illuminate\Http\Request; class MainPageController extends Controller { - public function index() + public function index(Request $request) { - $products = Product::query()->latest()->limit(100)->get(); - return view("index", ["products" => $products]); + $query = $request->query->get("q"); + if ($query) { + // O(n) query at best, malicious users can just insert % and _ characters into the query if they wanna, but it's fine half the class left every single field vulnurable to sqli so I don't wanna bother doing this properly with a full text search + $products = Product::query()->where('name', 'like', "%{$query}%")->orWhere('description', 'like', "?")->latest()->limit(100)->get(); + } else { + $products = Product::query()->latest()->limit(100)->get(); + } + return view("index", ["products" => $products, "query" => $query]); } } diff --git a/resources/scss/app.scss b/resources/scss/app.scss index 173a9ba..05ce550 100644 --- a/resources/scss/app.scss +++ b/resources/scss/app.scss @@ -32,10 +32,12 @@ nav { padding: 1em; } -nav .fa { - font-size: 4vh; +.form-search { + display:flex; + justify-content: center; } + main { display: flex; flex-direction: column; diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index b478cec..177e209 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -10,10 +10,15 @@