Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ _ide_helper_models.php
tests/Browser/Screenshots
/.github/git-commit-instructions.md
/.laracord
.claude
5 changes: 4 additions & 1 deletion app-modules/events/src/Actions/AttendEventAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Exception;
use He4rt\Events\Models\EventModel;
use He4rt\Events\Models\Pivot\EventAttend;

final class AttendEventAction
{
Expand All @@ -14,7 +15,9 @@ final class AttendEventAction
*/
public function execute(EventModel $eventModel): void
{
$attendingStatus = $eventModel->attendees()->first()->pivot->status;
/** @var EventAttend|null $pivot */
$pivot = $eventModel->attendees()->first()?->pivot;
$attendingStatus = $pivot->status;
$eventModel->attend(auth()->user()->id, $attendingStatus);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ public static function getGloballySearchableAttributes(): array

public static function getGlobalSearchResultDetails(Model $record): array
{
/** @var EventAgenda $record */
$details = [];

if ($record->tenant) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use He4rt\Events\Models\EventModel;
use He4rt\Identity\Filament\Admin\Resources\Users\UserResource;
use He4rt\Identity\User\Models\User;
use Illuminate\Database\Eloquent\Model;
Expand All @@ -27,6 +28,7 @@ class AttendeesRelationManager extends RelationManager

public static function getBadge(Model $ownerRecord, string $pageClass): ?string
{
/** @var EventModel $ownerRecord */
return (string) $ownerRecord->attendees()->count();
}

Expand All @@ -48,7 +50,11 @@ public function table(Table $table): Table
])
->recordActions([
DetachAction::make()
->using(fn (User $record) => $this->getOwnerRecord()->leave($record->getKey())),
->using(function (User $record): void {
/** @var EventModel $ownerRecord */
$ownerRecord = $this->getOwnerRecord();
$ownerRecord->leave($record->getKey());
}),
]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Filament\Support\Icons\Heroicon;
use Filament\Tables\Table;
use He4rt\Events\Filament\Admin\Resources\Talks\TalkResource;
use He4rt\Events\Models\EventModel;
use Illuminate\Database\Eloquent\Model;

class TalksRelationManager extends RelationManager
Expand All @@ -20,6 +21,7 @@ class TalksRelationManager extends RelationManager

public static function getBadge(Model $ownerRecord, string $pageClass): ?string
{
/** @var EventModel $ownerRecord */
return (string) $ownerRecord->talks()->count();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ public function leave(string|int $eventModelId): void
->send();
}

/**
* @param Builder<EventModel> $query
* @return Builder<EventModel>
*/
protected function modifyQueryWithActiveTab(Builder $query, bool $isResolvingRecord = false): Builder
{
return $query->where('active', true)->with('attendees')->latest('end_at');
Expand Down
7 changes: 5 additions & 2 deletions app-modules/events/src/Filament/Events/EventLandingPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,21 @@

use Filament\Pages\Dashboard;
use Filament\Support\Enums\Width;
use He4rt\Identity\Tenant\Models\Tenant;

class EventLandingPage extends Dashboard
{
public $tenant;
public ?Tenant $tenant = null;

protected static bool $shouldRegisterNavigation = false;

protected Width|string|null $maxContentWidth = Width::Full;

public function mount(): void
{
$this->tenant = filament()->getTenant();
/** @var Tenant|null $tenant */
$tenant = filament()->getTenant();
$this->tenant = $tenant;
}

public function getView(): string
Expand Down
10 changes: 5 additions & 5 deletions app-modules/events/src/Filament/Events/ParticipantDashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@
use He4rt\Identity\Tenant\Models\Tenant;
use Illuminate\Contracts\Support\Htmlable;

/** @property Tenant $tenant */
class ParticipantDashboard extends Page
{
/** @var Tenant|null */
public $tenant;
public ?Tenant $tenant = null;

/** @var EventModel|null */
public $event;
Expand All @@ -34,14 +32,16 @@ public function getTitle(): string|Htmlable

public function mount(): void
{
$this->tenant = filament()->getTenant();
/** @var Tenant $tenant */
$tenant = filament()->getTenant();
$this->tenant = $tenant;

$this->event = $this->tenant
->events()
->where('active', true)
->first();

abort_unless($this->event, 404);
abort_unless($this->event !== null, 404);
}

public function getView(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,21 @@ public static function getEloquentQuery(): Builder

public static function getGlobalSearchEloquentQuery(): Builder
{
return parent::getGlobalSearchEloquentQuery()->with(['event', 'user']);
return parent::getGlobalSearchEloquentQuery()->with(['submission.event', 'user']);
}

public static function getGloballySearchableAttributes(): array
{
return ['event.title', 'user.name'];
return ['submission.event.title', 'user.name'];
}

public static function getGlobalSearchResultDetails(Model $record): array
{
/** @var EventSubmissionSpeaker $record */
$details = [];

if ($record->event) {
$details['Event'] = $record->event->title;
if ($record->submission?->event) {
$details['Event'] = $record->submission->event->title;
}

if ($record->user) {
Expand Down
10 changes: 6 additions & 4 deletions app-modules/events/src/Filament/Shared/EventLogin.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,9 @@ public function defaultMultiFactorChallengeForm(Schema $schema): Schema
return [];
}

$authProvider = Filament::auth()->getProvider();
/** @phpstan-ignore-line */
/** @var SessionGuard $guard */
$guard = Filament::auth();
$authProvider = $guard->getProvider();
$user = $authProvider->retrieveById(decrypt($this->userUndertakingMultiFactorAuthentication));

$enabledMultiFactorAuthenticationProviders = array_filter(
Expand Down Expand Up @@ -341,8 +342,9 @@ protected function getRememberFormComponent(): Component

protected function getMultiFactorProviderFormComponent(): ?Component
{
$authProvider = Filament::auth()->getProvider();
/** @phpstan-ignore-line */
/** @var SessionGuard $guard */
$guard = Filament::auth();
$authProvider = $guard->getProvider();
$user = $authProvider->retrieveById(decrypt($this->userUndertakingMultiFactorAuthentication));

$enabledMultiFactorAuthenticationProviders = array_filter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,26 @@
use Filament\Forms\Components\DateTimePicker;
use Filament\Schemas\Components\Utilities\Get;
use He4rt\Events\Models\EventModel;
use Illuminate\Support\Facades\Date;

final class StartEndFieldsSchema
{
/** @return array<int, DateTimePicker> */
public static function make(): array
{
return [
DateTimePicker::make('starts_at')
->label('Starts at')
->minDate(function (Get $get): ?Carbon {

/** @var EventModel $event */
$event = EventModel::query()->where('id', $get('event_id'))->first();
if ($event) {
return Date::parse($event->start_at);
}

return null;
return $event?->start_at;
})
->required(),
DateTimePicker::make('ends_at')
->maxDate(function (Get $get): ?Carbon {

/** @var EventModel $event */
$event = EventModel::query()->where('id', $get('event_id'))->first();

if ($event) {
return Date::parse($event->end_at);
}

return null;
return $event?->end_at;
})
->after('starts_at')
->rules([
Expand Down
11 changes: 11 additions & 0 deletions app-modules/events/src/Models/EventAgenda.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace He4rt\Events\Models;

use Carbon\Carbon;
use He4rt\Events\Database\Factories\EventAgendaFactory;
use He4rt\Events\Enums\SchedulableTypeEnum;
use He4rt\Identity\Tenant\Models\Tenant;
Expand All @@ -17,10 +18,14 @@

/**
* @property string $schedulable_type
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
*/
#[UseFactory(EventAgendaFactory::class)]
class EventAgenda extends Model
{
/** @use HasFactory<EventAgendaFactory> */
use HasFactory;
use SoftDeletes;

Expand Down Expand Up @@ -51,11 +56,17 @@ public function event(): BelongsTo
return $this->belongsTo(EventModel::class, 'event_id');
}

/**
* @return MorphTo<Model, $this>
*/
public function schedulable(): MorphTo
{
return $this->morphTo();
}

/**
* @return Attribute<SchedulableTypeEnum, never>
*/
protected function scheduleType(): Attribute
{
return Attribute::get(fn () => SchedulableTypeEnum::from($this->schedulable_type));
Expand Down
Loading