Skip to content

Commit

Permalink
fix code style
Browse files Browse the repository at this point in the history
  • Loading branch information
AmonDeShir committed Dec 9, 2024
1 parent a75bf90 commit c80d0dd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
16 changes: 13 additions & 3 deletions app/Http/Controllers/SchoolsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,22 @@ public function destroy(School $school): RedirectResponse
->with("status", "Szkoła została usunięta.");
}

public function toggleDisable(School $school): RedirectResponse
public function disable(School $school): RedirectResponse
{
$school->is_disabled = !$school->is_disabled;
return $this->toggleDisable($school, false);
}

public function enable(School $school): RedirectResponse
{
return $this->toggleDisable($school, true);
}

public function toggleDisable(School $school, bool $value): RedirectResponse
{
$school->is_disabled = $value;
$school->save();

$message = $school->is_disabled ? "Szkoła została zablokowana." : "Szkoła została odblokowana.";
$message = $value ? "Szkoła została zablokowana." : "Szkoła została odblokowana.";

return redirect()
->back()
Expand Down
4 changes: 2 additions & 2 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@
Route::post("/schools", [SchoolsController::class, "store"])->name("admin.schools.store");
Route::patch("/schools/{school}", [SchoolsController::class, "update"])->name("admin.schools.update")->can("update,school");
Route::delete("/schools/{school}", [SchoolsController::class, "destroy"])->name("admin.schools.destroy")->can("delete,school");
Route::post("/schools/{school}/disable", [SchoolsController::class, "toggleDisable"])->name("admin.schools.disable")->can("disable,school");
Route::post("/schools/{school}/enable", [SchoolsController::class, "toggleDisable"])->name("admin.schools.enable")->can("enable,school");
Route::post("/schools/{school}/disable", [SchoolsController::class, "disable"])->name("admin.schools.disable")->can("disable,school");
Route::post("/schools/{school}/enable", [SchoolsController::class, "enable"])->name("admin.schools.enable")->can("enable,school");

Route::post("/schools/fetch", [SchoolsController::class, "fetch"])->name("admin.schools.fetch");
Route::get("/schools/status", [SchoolsController::class, "status"])->name("admin.schools.status");
Expand Down

0 comments on commit c80d0dd

Please sign in to comment.