-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
265 additions
and
354 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Enums; | ||
|
||
use App\Concerns\Enums\Arrayable; | ||
use App\Concerns\Enums\Comparable; | ||
use Filament\Support\Contracts\HasLabel; | ||
|
||
enum ElectionType: string implements HasLabel | ||
{ | ||
use Arrayable; | ||
use Comparable; | ||
|
||
case PRESIDENTIAL = 'presidential'; | ||
case PARLIAMENTARY = 'parliamentary'; | ||
case EURO = 'euro'; | ||
case LOCAL = 'local'; | ||
case REFERENDUM = 'referendum'; | ||
|
||
public function getLabel(): ?string | ||
{ | ||
return match ($this) { | ||
self::PRESIDENTIAL => __('app.election_type.presidential'), | ||
self::PARLIAMENTARY => __('app.election_type.parliamentary'), | ||
self::EURO => __('app.election_type.euro'), | ||
self::LOCAL => __('app.election_type.local'), | ||
self::REFERENDUM => __('app.election_type.referendum'), | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Models\Election; | ||
use Illuminate\Http\RedirectResponse; | ||
|
||
class RedirectToElectionController extends Controller | ||
{ | ||
public function __invoke(?Election $election = null): RedirectResponse | ||
{ | ||
$election ??= Election::latest()->first(); | ||
|
||
$route = $election->properties?->get('default_route') === 'results' | ||
? 'front.elections.results' | ||
: 'front.elections.turnout'; | ||
|
||
return redirect()->route($route, $election); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\View\Components\Election; | ||
|
||
use App\Models\Election; | ||
use Illuminate\Contracts\View\View; | ||
use Illuminate\Support\Collection; | ||
use Illuminate\Support\Facades\Route; | ||
use Illuminate\View\Component; | ||
|
||
class Header extends Component | ||
{ | ||
public Election $election; | ||
|
||
public Collection $items; | ||
|
||
public function __construct(Election $election) | ||
{ | ||
$this->election = $election; | ||
|
||
$this->items = collect([ | ||
'front.elections.turnout' => __('app.navigation.turnout'), | ||
'front.elections.results' => __('app.navigation.results'), | ||
]); | ||
} | ||
|
||
public function render(): View | ||
{ | ||
return view('components.election.header'); | ||
} | ||
|
||
public function isCurrent(string $route): bool | ||
{ | ||
return Route::currentRouteName() === $route; | ||
} | ||
} |
Oops, something went wrong.