Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
andreiio committed Nov 21, 2024
1 parent 23c588d commit a27b5bf
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
9 changes: 8 additions & 1 deletion app/Http/Controllers/RedirectToElectionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ class RedirectToElectionController extends Controller
{
public function __invoke(?Election $election = null): RedirectResponse
{
$election ??= Election::latest()->first();
$election ??= Election::query()
->where('is_visible', true)
->latest()
->first();

if (blank($election)) {
abort(404);
}

return redirect()->to($election->getDefaultUrl());
}
Expand Down
2 changes: 2 additions & 0 deletions app/Models/Election.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class Election extends Model implements HasName, HasAvatar
'subtitle',
'slug',
'date',
'is_visible',
'is_live',
'has_lists',
'properties',
Expand All @@ -41,6 +42,7 @@ protected function casts(): array
'type' => ElectionType::class,
'date' => 'date',
'year' => 'int',
'is_visible' => 'boolean',
'is_live' => 'boolean',
'has_lists' => 'boolean',
'properties' => 'collection',
Expand Down
1 change: 1 addition & 0 deletions app/View/Components/Timeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Timeline extends Component
public function __construct()
{
$this->years = Election::query()
->where('is_visible', true)
->get()
->groupBy([
'year',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public function up(): void
$table->string('slug')->unique();
$table->date('date');
$table->year('year')->storedAs('(YEAR(date))');
$table->boolean('is_live');
$table->boolean('is_visible')->default(true);
$table->boolean('is_live')->default(false);
$table->boolean('has_lists')->default(false);
$table->json('properties')->nullable();
$table->timestamps();
Expand Down

0 comments on commit a27b5bf

Please sign in to comment.