|
7 | 7 | use App\Http\Controllers\Controller; |
8 | 8 | use App\Http\Resources\StationResource; |
9 | 9 | use App\Models\Station; |
10 | | -use App\Services\StationService; |
11 | 10 | use App\Services\Wikidata\WikidataImportService; |
12 | 11 | use Illuminate\Auth\Access\AuthorizationException; |
13 | 12 | use Illuminate\Http\JsonResponse; |
14 | 13 | use Illuminate\Http\RedirectResponse; |
15 | 14 | use Illuminate\Http\Request; |
16 | 15 | use Illuminate\Support\Facades\Log; |
17 | | -use Illuminate\View\View; |
18 | 16 |
|
19 | 17 | class StationController extends Controller |
20 | 18 | { |
21 | | - public function index(Request $request): View|RedirectResponse |
22 | | - { |
23 | | - $this->authorize('viewAny', Station::class); |
24 | | - $stations = Station::orderByDesc('created_at'); |
25 | | - if ($request->has('query')) { |
26 | | - $query = strip_tags($request->get('query')); |
27 | | - |
28 | | - if (is_numeric($query)) { |
29 | | - $stations->where('id', $query); |
30 | | - if ($stations->exists()) { |
31 | | - return redirect()->route('admin.station', ['id' => $query]); |
32 | | - } |
33 | | - } |
34 | | - |
35 | | - $stations->where('name', 'LIKE', '%' . $query . '%'); |
36 | | - |
37 | | - if ($stations->count() === 1) { |
38 | | - return redirect()->route('admin.station', ['id' => $stations->first()->id]); |
39 | | - } |
40 | | - } |
41 | | - |
42 | | - return view('admin.stations.index', [ |
43 | | - 'stations' => $stations->paginate(20), |
44 | | - ]); |
45 | | - } |
46 | | - |
47 | | - public function show(int $id): View |
48 | | - { |
49 | | - $this->authorize('viewAny', Station::class); |
50 | | - |
51 | | - $station = Station::findOrFail($id); |
52 | | - |
53 | | - return view('admin.stations.show', [ |
54 | | - 'station' => $station, |
55 | | - 'nearbyStations' => StationService::getNearbyStations($station), |
56 | | - 'latestCheckins' => StationService::getLatestCheckins($station), |
57 | | - ]); |
58 | | - } |
59 | | - |
60 | 19 | /** |
61 | 20 | * !!!! Experimental Backend Function !!!! |
62 | 21 | * Fetches the Wikidata information for a station. |
|
0 commit comments