-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
42e3c07
commit 6032e78
Showing
25 changed files
with
671 additions
and
189 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
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
26 changes: 26 additions & 0 deletions
26
app/Filament/Resources/OrganizationResource/Pages/OrganisationIndex.php
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,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Filament\Resources\OrganizationResource\Pages; | ||
|
||
use App\Filament\Resources\OrganizationResource; | ||
use Filament\Resources\Pages\Page; | ||
|
||
class OrganisationIndex extends Page | ||
{ | ||
protected static string $resource = OrganizationResource::class; | ||
|
||
protected static string $view = 'filament.resources.organization-resource.pages.organisation-index'; | ||
|
||
protected static ?string $title = ''; | ||
|
||
protected function getHeaderWidgets(): array | ||
{ | ||
return [ | ||
OrganizationResource\Widgets\NewOrganizationWidget::class, | ||
OrganizationResource\Widgets\ApprovedOrganizationWidget::class, | ||
OrganizationResource\Widgets\RejectedOrganizationWidget::class, | ||
]; | ||
} | ||
} |
95 changes: 95 additions & 0 deletions
95
app/Filament/Resources/OrganizationResource/Widgets/ApprovedOrganizationWidget.php
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,95 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Filament\Resources\OrganizationResource\Widgets; | ||
|
||
use App\Enums\OrganizationStatus; | ||
use App\Filament\Resources\OrganizationResource; | ||
use App\Models\Organization; | ||
use Filament\Tables\Actions\Action; | ||
use Filament\Tables\Concerns\CanPaginateRecords; | ||
use Filament\Widgets\TableWidget as BaseWidget; | ||
use Illuminate\Database\Eloquent\Builder; | ||
|
||
class ApprovedOrganizationWidget extends BaseWidget | ||
{ | ||
use CanPaginateRecords { | ||
paginateTableQuery as protected; | ||
} | ||
|
||
/** @var string */ | ||
protected static string $resource = OrganizationResource::class; | ||
|
||
protected static ?int $sort = 1; | ||
|
||
protected int|string|array $columnSpan = [ | ||
'lg' => 2, | ||
]; | ||
|
||
protected static ?string $recordTitleAttribute = 'title'; | ||
|
||
public static function canView(): bool | ||
{ | ||
return true; | ||
} | ||
|
||
protected function getTableHeading(): string | ||
{ | ||
return __('organization.heading.approved'); | ||
} | ||
|
||
protected function getTableQuery(): Builder | ||
{ | ||
return Organization::isApproved(); | ||
} | ||
|
||
protected function getTableQueryStringIdentifier(): ?string | ||
{ | ||
return 'approved_organization'; | ||
} | ||
|
||
protected function getDefaultTableSortColumn(): ?string | ||
{ | ||
return 'id'; | ||
} | ||
|
||
protected function getDefaultTableSortDirection(): ?string | ||
{ | ||
return 'desc'; | ||
} | ||
|
||
protected function getTableColumns(): array | ||
{ | ||
return self::$resource::getWidgetColumns(); | ||
} | ||
|
||
protected function getTableFilters(): array | ||
{ | ||
return [ | ||
|
||
]; | ||
} | ||
|
||
protected function getTableRecordUrlUsing(): \Closure | ||
{ | ||
return fn (Organization $record) => OrganizationResource::getUrl('edit', [ | ||
'record' => $record, | ||
]); | ||
} | ||
|
||
protected function getTableActions(): array | ||
{ | ||
return [ | ||
Action::make('view') | ||
->label(__('organization.actions.edit')) | ||
->url(self::getTableRecordUrlUsing()) | ||
->size('sm') | ||
->icon(null), | ||
Action::make('reject') | ||
->label(__('organization.actions.reject')) | ||
->action(fn (Organization $record) => $record->status = OrganizationStatus::rejected->value) | ||
->size('sm') | ||
->icon(null), ]; | ||
} | ||
} |
102 changes: 102 additions & 0 deletions
102
app/Filament/Resources/OrganizationResource/Widgets/NewOrganizationWidget.php
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,102 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Filament\Resources\OrganizationResource\Widgets; | ||
|
||
use App\Enums\OrganizationStatus; | ||
use App\Filament\Resources\OrganizationResource; | ||
use App\Models\Organization; | ||
use Filament\Tables\Actions\Action; | ||
use Filament\Tables\Concerns\CanPaginateRecords; | ||
use Filament\Widgets\TableWidget as BaseWidget; | ||
use Illuminate\Database\Eloquent\Builder; | ||
|
||
class NewOrganizationWidget extends BaseWidget | ||
{ | ||
use CanPaginateRecords { | ||
paginateTableQuery as protected; | ||
} | ||
|
||
protected static ?int $sort = 1; | ||
|
||
/** @var string */ | ||
protected static string $resource = OrganizationResource::class; | ||
|
||
protected int|string|array $columnSpan = [ | ||
'lg' => 2, | ||
]; | ||
|
||
protected static ?string $recordTitleAttribute = 'title'; | ||
|
||
public static function canView(): bool | ||
{ | ||
return true; | ||
} | ||
|
||
protected function getTableHeading(): string | ||
{ | ||
return __('organization.heading.in_approval'); | ||
} | ||
|
||
protected function getTableQuery(): Builder | ||
{ | ||
return Organization::query()->isPending(); | ||
} | ||
|
||
protected function getTableQueryStringIdentifier(): ?string | ||
{ | ||
return 'new_organization'; | ||
} | ||
|
||
protected function getDefaultTableSortColumn(): ?string | ||
{ | ||
return 'id'; | ||
} | ||
|
||
protected function getDefaultTableSortDirection(): ?string | ||
{ | ||
return 'desc'; | ||
} | ||
|
||
protected function getTableColumns(): array | ||
{ | ||
return self::$resource::getWidgetColumns(); | ||
} | ||
|
||
protected function getTableFilters(): array | ||
{ | ||
return [ | ||
|
||
]; | ||
} | ||
|
||
protected function getTableRecordUrlUsing(): \Closure | ||
{ | ||
return fn (Organization $record) => OrganizationResource::getUrl('edit', [ | ||
'record' => $record, | ||
]); | ||
} | ||
|
||
protected function getTableActions(): array | ||
{ | ||
return [ | ||
Action::make('edit') | ||
->label(__('organization.actions.edit')) | ||
->url(self::getTableRecordUrlUsing()) | ||
->size('sm') | ||
->icon(null), | ||
Action::make('accept') | ||
->label(__('organization.actions.approve')) | ||
->size('sm') | ||
->icon(null) | ||
->action(fn (Organization $record) => $record->status = OrganizationStatus::approved->value) | ||
->requiresConfirmation(), | ||
Action::make('reject') | ||
->label(__('organization.actions.reject')) | ||
->action(fn (Organization $record) => $record->status = OrganizationStatus::rejected->value) | ||
->size('sm') | ||
->icon(null), | ||
]; | ||
} | ||
} |
Oops, something went wrong.