Skip to content

Commit

Permalink
- fix api routes (#221)
Browse files Browse the repository at this point in the history
* fix api routes

* lint
  • Loading branch information
AleksandraKozubal authored Apr 8, 2024
1 parent 06c0008 commit 911b999
Showing 1 changed file with 35 additions and 33 deletions.
68 changes: 35 additions & 33 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,41 +19,43 @@
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

Route::middleware("auth:api")->get("/user", fn(Request $request): JsonResponse => new JsonResponse($request->user()));
Route::get("/providers", [CityProviderController::class, "index"]);
Route::name("api.")->group(function (): void {
Route::middleware("auth:api")->get("/user", fn(Request $request): JsonResponse => new JsonResponse($request->user()));
Route::get("/providers", [CityProviderController::class, "index"]);

Route::middleware("guest")->group(function (): void {
Route::post("/register", [AuthController::class, "store"])->name("register");
Route::post("/login", [AuthController::class, "login"])->name("login");
});
Route::middleware("guest")->group(function (): void {
Route::post("/register", [AuthController::class, "store"])->name("register");
Route::post("/login", [AuthController::class, "login"])->name("login");
});

Route::middleware("auth:sanctum")->group(function (): void {
Route::post("/logout", [AuthController::class, "logout"])->name("logout");

Route::post("/favorites", [FavoritesController::class, "store"]);
Route::get("/favorites/{city_id}", [FavoritesController::class, "check"]);
Route::get("/favorite-cities", [FavoritesController::class, "index"]);

Route::post("/opinions", [CityOpinionController::class, "store"]);
Route::patch("/opinions/{cityOpinion}", [CityOpinionController::class, "update"]);
Route::delete("/opinions/{cityOpinion}", [CityOpinionController::class, "destroy"]);

Route::middleware("ability:HasAdminRole")->group(function (): void {
Route::get("/admin/importers", [ImportInfoController::class, "index"]);
Route::resource("/admin/providers", ProviderController::class);
Route::resource("/admin/countries", CountryController::class);
Route::resource("/admin/cities", CityController::class);
Route::resource("/admin/dashboard", DashboardController::class);
Route::resource("/city-alternative-name", CityAlternativeNameController::class);
Route::patch("/update-city-providers/{city}", [CityProviderController::class, "update"]);

Route::post("/run-importers", [CityProviderController::class, "runImporters"]);
Route::delete("/delete-city-without-assigned-country/{city}", [CityWithoutAssignedCountryController::class, "destroy"]);
Route::post("/delete-all-cities-without-assigned-country", [CityWithoutAssignedCountryController::class, "destroyAll"]);
Route::middleware("auth:sanctum")->group(function (): void {
Route::post("/logout", [AuthController::class, "logout"])->name("logout");

Route::post("/favorites", [FavoritesController::class, "store"]);
Route::get("/favorites/{city_id}", [FavoritesController::class, "check"]);
Route::get("/favorite-cities", [FavoritesController::class, "index"]);

Route::post("/opinions", [CityOpinionController::class, "store"]);
Route::patch("/opinions/{cityOpinion}", [CityOpinionController::class, "update"]);
Route::delete("/opinions/{cityOpinion}", [CityOpinionController::class, "destroy"]);

Route::middleware("ability:HasAdminRole")->group(function (): void {
Route::get("/admin/importers", [ImportInfoController::class, "index"]);
Route::resource("/admin/providers", ProviderController::class);
Route::resource("/admin/countries", CountryController::class);
Route::resource("/admin/cities", CityController::class);
Route::resource("/admin/dashboard", DashboardController::class);
Route::resource("/city-alternative-name", CityAlternativeNameController::class);
Route::patch("/update-city-providers/{city}", [CityProviderController::class, "update"]);

Route::post("/run-importers", [CityProviderController::class, "runImporters"]);
Route::delete("/delete-city-without-assigned-country/{city}", [CityWithoutAssignedCountryController::class, "destroy"]);
Route::post("/delete-all-cities-without-assigned-country", [CityWithoutAssignedCountryController::class, "destroyAll"]);
});
});
});
Route::post("/language/{locale}", ChangeLocaleController::class);
Route::post("/language/{locale}", ChangeLocaleController::class);

Route::get("/{country:slug}/{city:slug}", [CityPageController::class, "index"]);
Route::get("/{country:slug}/{city:slug}", [CityPageController::class, "index"]);

Route::get("/images/providers/{filename}", [ProviderController::class, "showLogo"]);
Route::get("/images/providers/{filename}", [ProviderController::class, "showLogo"]);
});

0 comments on commit 911b999

Please sign in to comment.