Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADVAPP-283]: Introduce Custom Reporting Capabilities #478

Merged
merged 13 commits into from
Feb 1, 2024
2 changes: 1 addition & 1 deletion app-modules/analytics/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "canyon-gbs/analytics",
"name": "canyon-gbs/advising-app-analytics",
"description": "",
"type": "library",
"version": "1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@

</COPYRIGHT>
--}}
@php
use AdvisingApp\CaseloadManagement\Enums\CaseloadType;
@endphp

<x-filament-panels::page @class([
'fi-resource-edit-record-page',
'fi-resource-' . str_replace('/', '-', $this->getResource()::getSlug()),
Expand Down
31 changes: 21 additions & 10 deletions app-modules/caseload-management/src/Enums/CaseloadModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,13 @@

namespace AdvisingApp\CaseloadManagement\Enums;

use Filament\Tables\Table;
use Filament\Support\Contracts\HasLabel;
use AdvisingApp\Prospect\Models\Prospect;
use Illuminate\Database\Eloquent\Builder;
use AdvisingApp\StudentDataModel\Models\Student;
use AdvisingApp\Prospect\Filament\Tables\ProspectsTable;
use AdvisingApp\StudentDataModel\Filament\Tables\StudentsTable;
use AdvisingApp\CaseloadManagement\Importers\StudentCaseloadSubjectImporter;
use AdvisingApp\CaseloadManagement\Importers\ProspectCaseloadSubjectImporter;

Expand All @@ -54,34 +57,42 @@ public function getLabel(): ?string
return $this->name;
}

public static function default(): CaseloadModel
public static function default(): static
{
return CaseloadModel::Student;
return static::Student;
}

public function query(): Builder
{
return match ($this) {
CaseloadModel::Student => Student::query(),
CaseloadModel::Prospect => Prospect::query(),
static::Student => Student::query(),
static::Prospect => Prospect::query(),
};
}

public function class(): string
{
return match ($this) {
CaseloadModel::Student => Student::class,
CaseloadModel::Prospect => Prospect::class,
static::Student => Student::class,
static::Prospect => Prospect::class,
};
}

public static function tryFromCaseOrValue(CaseloadModel | string $value): ?CaseloadModel
public function table(Table $table): Table
{
return $table->tap(app(match ($this) {
static::Student => StudentsTable::class,
static::Prospect => ProspectsTable::class,
}));
}

public static function tryFromCaseOrValue(CaseloadModel | string $value): ?static
{
if ($value instanceof CaseloadModel) {
return $value;
}

return CaseloadModel::tryFrom($value);
return static::tryFrom($value);
}

/**
Expand All @@ -90,8 +101,8 @@ public static function tryFromCaseOrValue(CaseloadModel | string $value): ?Casel
public function getSubjectImporter(): string
{
return match ($this) {
CaseloadModel::Prospect => ProspectCaseloadSubjectImporter::class,
CaseloadModel::Student => StudentCaseloadSubjectImporter::class,
static::Prospect => ProspectCaseloadSubjectImporter::class,
static::Student => StudentCaseloadSubjectImporter::class,
};
}
}
10 changes: 5 additions & 5 deletions app-modules/caseload-management/src/Enums/CaseloadType.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,19 @@ enum CaseloadType: string implements HasLabel
public function getLabel(): ?string
{
return match ($this) {
CaseloadType::Static => 'Static',
static::Static => 'Static',
default => $this->name,
};
}

public static function default(): CaseloadType
public static function default(): static
{
return CaseloadType::Dynamic;
return static::Dynamic;
}

public static function tryFromCaseOrValue(CaseloadType | string $value): ?CaseloadType
public static function tryFromCaseOrValue(CaseloadType | string $value): ?static
{
if ($value instanceof CaseloadType) {
if ($value instanceof static) {
return $value;
}

Expand Down
Loading