Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
andreiio committed Nov 21, 2023
1 parent 8e8703c commit a13ce60
Show file tree
Hide file tree
Showing 54 changed files with 18,226 additions and 90 deletions.
32 changes: 32 additions & 0 deletions app/Concerns/BelongsToOrganization.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

namespace App\Concerns;

use App\Models\Organization;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

trait BelongsToOrganization
{
public function initializeBelongsToOrganization(): void
{
$this->fillable[] = 'organization_id';
}

protected static function bootBelongsToOrganization(): void
{
static::creating(function (self $model) {
if (! auth()->check()) {
return;
}

$model->organization_id = auth()->user()->organization_id;
});
}

public function organization(): BelongsTo
{
return $this->belongsTo(Organization::class);
}
}
18 changes: 18 additions & 0 deletions app/Filament/Pages/Dashboard.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace App\Filament\Pages;

use Filament\Pages\Dashboard as BaseDashboard;
use Illuminate\Contracts\Support\Htmlable;

class Dashboard extends BaseDashboard
{
public function getHeading(): string | Htmlable
{
return __('dashboard.welcome', [
'name' => auth()->user()->first_name,
]);
}
}
26 changes: 26 additions & 0 deletions app/Filament/Pages/Tenancy/EditOrganizationProfile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

namespace App\Filament\Pages\Tenancy;

use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Pages\Tenancy\EditTenantProfile;

class EditOrganizationProfile extends EditTenantProfile
{
public static function getLabel(): string
{
return 'Team profile';
}

public function form(Form $form): Form
{
return $form
->schema([
TextInput::make('name'),
// ...
]);
}
}
82 changes: 82 additions & 0 deletions app/Filament/Resources/BeneficiaryResource.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?php

declare(strict_types=1);

namespace App\Filament\Resources;

use App\Filament\Resources\BeneficiaryResource\Pages;
use App\Models\Beneficiary;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;

class BeneficiaryResource extends Resource
{
protected static ?string $model = Beneficiary::class;

protected static ?string $navigationIcon = 'heroicon-o-users';

public static function getNavigationGroup(): ?string
{
return __('navigation.beneficiaries._group');
}

public static function getNavigationLabel(): string
{
return __('navigation.beneficiaries.cases');
}

public static function getModelLabel(): string
{
return __('beneficiary.label.singular');
}

public static function getPluralModelLabel(): string
{
return __('beneficiary.label.plural');
}

public static function form(Form $form): Form
{
return $form
->schema([
//
]);
}

public static function table(Table $table): Table
{
return $table
->columns([
//
])
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
]);
}

public static function getRelations(): array
{
return [
//
];
}

public static function getPages(): array
{
return [
'index' => Pages\ListBeneficiaries::route('/'),
'create' => Pages\CreateBeneficiary::route('/create'),
'edit' => Pages\EditBeneficiary::route('/{record}/edit'),
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

namespace App\Filament\Resources\BeneficiaryResource\Pages;

use App\Filament\Resources\BeneficiaryResource;
use Filament\Resources\Pages\CreateRecord;

class CreateBeneficiary extends CreateRecord
{
protected static string $resource = BeneficiaryResource::class;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace App\Filament\Resources\BeneficiaryResource\Pages;

use App\Filament\Resources\BeneficiaryResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;

class EditBeneficiary extends EditRecord
{
protected static string $resource = BeneficiaryResource::class;

protected function getHeaderActions(): array
{
return [
Actions\DeleteAction::make(),
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace App\Filament\Resources\BeneficiaryResource\Pages;

use App\Filament\Resources\BeneficiaryResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;

class ListBeneficiaries extends ListRecords
{
protected static string $resource = BeneficiaryResource::class;

protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
];
}
}
90 changes: 90 additions & 0 deletions app/Filament/Resources/UserResource.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?php

declare(strict_types=1);

namespace App\Filament\Resources;

use App\Filament\Resources\UserResource\Pages;
use App\Models\User;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;

class UserResource extends Resource
{
protected static ?string $model = User::class;

protected static ?string $navigationIcon = 'heroicon-o-user-group';

protected static ?string $tenantOwnershipRelationshipName = 'organizations';

public static function getNavigationGroup(): ?string
{
return __('navigation.configurations._group');
}

public static function getNavigationLabel(): string
{
return __('navigation.configurations.staff');
}

public static function getModelLabel(): string
{
return __('user.label.singular');
}

public static function getPluralModelLabel(): string
{
return __('user.label.plural');
}

public static function form(Form $form): Form
{
return $form
->schema([
//
]);
}

public static function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('first_name'),
TextColumn::make('last_name'),
TextColumn::make('roles'),
TextColumn::make('account_status'),
TextColumn::make('last_login_at'),

])
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
]);
}

public static function getRelations(): array
{
return [
//
];
}

public static function getPages(): array
{
return [
'index' => Pages\ListUsers::route('/'),
'create' => Pages\CreateUser::route('/create'),
'edit' => Pages\EditUser::route('/{record}/edit'),
];
}
}
12 changes: 12 additions & 0 deletions app/Filament/Resources/UserResource/Pages/CreateUser.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace App\Filament\Resources\UserResource\Pages;

use App\Filament\Resources\UserResource;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;

class CreateUser extends CreateRecord
{
protected static string $resource = UserResource::class;
}
19 changes: 19 additions & 0 deletions app/Filament/Resources/UserResource/Pages/EditUser.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace App\Filament\Resources\UserResource\Pages;

use App\Filament\Resources\UserResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;

class EditUser extends EditRecord
{
protected static string $resource = UserResource::class;

protected function getHeaderActions(): array
{
return [
Actions\DeleteAction::make(),
];
}
}
19 changes: 19 additions & 0 deletions app/Filament/Resources/UserResource/Pages/ListUsers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace App\Filament\Resources\UserResource\Pages;

use App\Filament\Resources\UserResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;

class ListUsers extends ListRecords
{
protected static string $resource = UserResource::class;

protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
];
}
}
24 changes: 24 additions & 0 deletions app/Filament/Widgets/Organizations/CaseStatsWidget.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

namespace App\Filament\Widgets\Organizations;

use Filament\Widgets\StatsOverviewWidget as BaseWidget;
use Filament\Widgets\StatsOverviewWidget\Stat;

class CaseStatsWidget extends BaseWidget
{
protected static bool $isLazy = false;

protected function getStats(): array
{
return [
Stat::make(__('beneficiary.stats.open'), 25),

Stat::make(__('beneficiary.stats.monitoring'), 21),

Stat::make(__('beneficiary.stats.closed'), 312),
];
}
}
Loading

0 comments on commit a13ce60

Please sign in to comment.