2023-04-03 10:47:55 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Fo;
|
|
|
|
|
|
2025-07-15 15:59:36 +02:00
|
|
|
use App\Enums\StaticPageType;
|
2023-04-05 09:46:24 +00:00
|
|
|
use App\Http\Controllers\Controller;
|
2023-05-05 10:07:01 +02:00
|
|
|
use App\Http\Requests\Api\StoreFinderRequest;
|
|
|
|
|
use App\Http\Resources\StoreFinderResource;
|
2025-07-15 15:59:36 +02:00
|
|
|
use App\Models\StaticPage;
|
2023-05-05 10:07:01 +02:00
|
|
|
use App\Models\Store;
|
2023-04-03 10:47:55 +00:00
|
|
|
|
|
|
|
|
class StoreController extends Controller
|
|
|
|
|
{
|
2025-07-15 15:59:36 +02:00
|
|
|
/**
|
|
|
|
|
* Store page.
|
|
|
|
|
*
|
|
|
|
|
* @return \Illuminate\Contracts\View\View
|
|
|
|
|
*/
|
|
|
|
|
public function index(): \Illuminate\Contracts\View\View
|
|
|
|
|
{
|
|
|
|
|
$staticPageModel = StaticPage::query()->where('type', StaticPageType::store)->firstOrFail();
|
|
|
|
|
return view('fo.pages.storefinder', compact('staticPageModel'));
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-03 10:47:55 +00:00
|
|
|
/**
|
2025-07-10 15:19:04 +02:00
|
|
|
* Store by city.
|
2023-04-03 10:47:55 +00:00
|
|
|
*
|
2023-05-05 10:07:01 +02:00
|
|
|
* @param \App\Http\Requests\Api\StoreFinderRequest $request
|
2025-07-10 15:19:04 +02:00
|
|
|
* @return \Illuminate\Http\JsonResponse
|
2023-04-03 10:47:55 +00:00
|
|
|
*/
|
2025-07-10 15:19:04 +02:00
|
|
|
public function city(StoreFinderRequest $request): \Illuminate\Http\JsonResponse
|
2023-04-03 10:47:55 +00:00
|
|
|
{
|
2023-05-05 10:07:01 +02:00
|
|
|
return \response()->json(new StoreFinderResource(Store::query()
|
|
|
|
|
->where('city', 'LIKE', '%' . $request->input('city') . '%')
|
|
|
|
|
->orWhere('zipcode', 'LIKE', '%' . $request->input('city') . '%')
|
2023-05-05 10:31:53 +02:00
|
|
|
->orderBy('order')
|
2023-05-05 10:07:01 +02:00
|
|
|
->get()));
|
2023-04-03 10:47:55 +00:00
|
|
|
}
|
|
|
|
|
}
|