init
This commit is contained in:
232 files changed
+25416
No files matched your search
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages\Tenancy;
|
||||
|
||||
use App\Jobs\SyncCafeBazaarApp;
|
||||
use App\Models\MobileApp;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms\Components\KeyValue;
|
||||
use Filament\Forms\Components\Placeholder;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Pages\Tenancy\EditTenantProfile;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
|
||||
class EditMobileAppProfile extends EditTenantProfile
|
||||
{
|
||||
public static function getLabel(): string
|
||||
{
|
||||
return 'App settings';
|
||||
}
|
||||
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema->components([
|
||||
Section::make('App identity and availability')->schema([
|
||||
TextInput::make('name')->required()->maxLength(255),
|
||||
TextInput::make('package_name')->required()->regex('/^[A-Za-z][A-Za-z0-9_]*(\.[A-Za-z][A-Za-z0-9_]*)+$/')->unique(MobileApp::class, ignoreRecord: true)->maxLength(255),
|
||||
Toggle::make('is_active')->required(),
|
||||
Toggle::make('maintenance_mode')->required(),
|
||||
TextInput::make('latest_version_name')->maxLength(255),
|
||||
TextInput::make('latest_version_code')->numeric()->minValue(1),
|
||||
TextInput::make('minimum_version_code')->numeric()->minValue(1),
|
||||
TextInput::make('store_url')->url(),
|
||||
TextInput::make('privacy_url')->url(),
|
||||
TextInput::make('support_email')->email(),
|
||||
])->columns(2)->columnSpanFull(),
|
||||
Section::make('API access')->description('Use the client key in Android requests. Keep the management key only on trusted servers and in this panel.')->schema([
|
||||
TextInput::make('client_key')->password()->revealable()->required(),
|
||||
TextInput::make('management_key')->password()->revealable()->required(),
|
||||
])->columns(2)->columnSpanFull(),
|
||||
Section::make('Remote configuration')->schema([
|
||||
KeyValue::make('configuration')->keyLabel('Key')->valueLabel('Value')->columnSpanFull(),
|
||||
KeyValue::make('feature_flags')->keyLabel('Feature')->valueLabel('Enabled or value')->columnSpanFull(),
|
||||
])->columnSpanFull(),
|
||||
Section::make('Cafe Bazaar server API')->description('Per-app tokens from Pishkhan. Secrets are encrypted in the database.')->schema([
|
||||
TextInput::make('bazaar_api_secret')->password()->revealable()->label('Billing and Pishkhan API secret'),
|
||||
TextInput::make('bazaar_comments_header')->label('Comments API header name')->default('CAFEBAZAAR-PISHKHAN-API-SECRET'),
|
||||
TextInput::make('bazaar_comments_secret')->password()->revealable()->label('Comments API secret'),
|
||||
Textarea::make('bazaar_billing_public_key')->rows(5)->label('RSA billing public key')->columnSpanFull(),
|
||||
])->columns(2)->columnSpanFull(),
|
||||
Section::make('Cafe Bazaar synchronization')->description('Refreshes known purchases and subscriptions, imports reviews, and reconciles release state in the background.')->schema([
|
||||
Toggle::make('bazaar_sync_enabled')->label('Automatic synchronization')->required(),
|
||||
TextInput::make('bazaar_sync_interval_minutes')->label('Subscription sync interval (minutes)')->numeric()->minValue(5)->maxValue(1440)->required(),
|
||||
Placeholder::make('bazaar_sync_status')->label('Last result')->content(fn (?MobileApp $record): string => ucfirst($record?->bazaar_sync_status ?? 'idle')),
|
||||
Placeholder::make('bazaar_last_synced_at')->label('Last completed')->content(fn (?MobileApp $record): string => $record?->bazaar_last_synced_at?->diffForHumans() ?? 'Never'),
|
||||
Placeholder::make('bazaar_sync_error')->label('Last error')->content(fn (?MobileApp $record): string => $record?->bazaar_sync_error ?? 'None')->columnSpanFull(),
|
||||
])->columns(2)->columnSpanFull(),
|
||||
Section::make('Login with Bazaar')->schema([
|
||||
TextInput::make('bazaar_login_client_id')->label('Client ID'),
|
||||
TextInput::make('bazaar_login_client_secret')->password()->revealable()->label('Client secret'),
|
||||
TextInput::make('bazaar_login_redirect_url')->url()->label('Registered redirect URL')->columnSpanFull(),
|
||||
])->columns(2)->columnSpanFull(),
|
||||
]);
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('syncBazaar')
|
||||
->label('Sync Bazaar now')
|
||||
->icon(Heroicon::ArrowPath)
|
||||
->requiresConfirmation()
|
||||
->action(function (): void {
|
||||
/** @var MobileApp $app */
|
||||
$app = Filament::getTenant();
|
||||
SyncCafeBazaarApp::dispatch($app->id, true);
|
||||
|
||||
Notification::make()
|
||||
->title('Cafe Bazaar synchronization queued')
|
||||
->body('The dashboard status will update when the background worker finishes.')
|
||||
->success()
|
||||
->send();
|
||||
}),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages\Tenancy;
|
||||
|
||||
use App\Models\MobileApp;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Pages\Tenancy\RegisterTenant;
|
||||
use Filament\Schemas\Schema;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class RegisterMobileApp extends RegisterTenant
|
||||
{
|
||||
public static function getLabel(): string
|
||||
{
|
||||
return 'Add Android app';
|
||||
}
|
||||
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema->components([
|
||||
TextInput::make('name')->required()->maxLength(255),
|
||||
TextInput::make('package_name')->required()->regex('/^[A-Za-z][A-Za-z0-9_]*(\.[A-Za-z][A-Za-z0-9_]*)+$/')->unique(MobileApp::class)->maxLength(255),
|
||||
]);
|
||||
}
|
||||
|
||||
protected function handleRegistration(array $data): MobileApp
|
||||
{
|
||||
$mobileApp = MobileApp::create([
|
||||
...$data,
|
||||
'client_key' => Str::random(48),
|
||||
'management_key' => Str::random(64),
|
||||
'store_url' => 'https://cafebazaar.ir/app/'.$data['package_name'],
|
||||
]);
|
||||
|
||||
$mobileApp->users()->attach(auth()->user(), ['role' => 'owner']);
|
||||
|
||||
return $mobileApp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BazaarApiRequests;
|
||||
|
||||
use App\Filament\Resources\BazaarApiRequests\Pages\ListBazaarApiRequests;
|
||||
use App\Filament\Resources\BazaarApiRequests\Pages\ViewBazaarApiRequest;
|
||||
use App\Filament\Resources\BazaarApiRequests\Schemas\BazaarApiRequestForm;
|
||||
use App\Filament\Resources\BazaarApiRequests\Schemas\BazaarApiRequestInfolist;
|
||||
use App\Filament\Resources\BazaarApiRequests\Tables\BazaarApiRequestsTable;
|
||||
use App\Models\BazaarApiRequest;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
use UnitEnum;
|
||||
|
||||
class BazaarApiRequestResource extends Resource
|
||||
{
|
||||
protected static ?string $model = BazaarApiRequest::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleStack;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Cafe Bazaar';
|
||||
|
||||
protected static ?string $navigationLabel = 'API activity';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return BazaarApiRequestForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function infolist(Schema $schema): Schema
|
||||
{
|
||||
return BazaarApiRequestInfolist::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return BazaarApiRequestsTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListBazaarApiRequests::route('/'),
|
||||
'view' => ViewBazaarApiRequest::route('/{record}'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BazaarApiRequests\Pages;
|
||||
|
||||
use App\Filament\Resources\BazaarApiRequests\BazaarApiRequestResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateBazaarApiRequest extends CreateRecord
|
||||
{
|
||||
protected static string $resource = BazaarApiRequestResource::class;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BazaarApiRequests\Pages;
|
||||
|
||||
use App\Filament\Resources\BazaarApiRequests\BazaarApiRequestResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditBazaarApiRequest extends EditRecord
|
||||
{
|
||||
protected static string $resource = BazaarApiRequestResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
ViewAction::make(),
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BazaarApiRequests\Pages;
|
||||
|
||||
use App\Filament\Resources\BazaarApiRequests\BazaarApiRequestResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListBazaarApiRequests extends ListRecords
|
||||
{
|
||||
protected static string $resource = BazaarApiRequestResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BazaarApiRequests\Pages;
|
||||
|
||||
use App\Filament\Resources\BazaarApiRequests\BazaarApiRequestResource;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewBazaarApiRequest extends ViewRecord
|
||||
{
|
||||
protected static string $resource = BazaarApiRequestResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BazaarApiRequests\Schemas;
|
||||
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class BazaarApiRequestForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
//
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BazaarApiRequests\Schemas;
|
||||
|
||||
use Filament\Infolists\Components\IconEntry;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class BazaarApiRequestInfolist
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextEntry::make('operation')->badge(),
|
||||
TextEntry::make('method')->badge(),
|
||||
TextEntry::make('url')->columnSpanFull(),
|
||||
TextEntry::make('status_code'),
|
||||
IconEntry::make('successful')->boolean(),
|
||||
TextEntry::make('duration_ms')->suffix(' ms'),
|
||||
TextEntry::make('request_metadata')->formatStateUsing(fn (?array $state): string => json_encode($state, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE))->columnSpanFull(),
|
||||
TextEntry::make('response_body')->formatStateUsing(fn (?array $state): string => json_encode($state, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE))->columnSpanFull(),
|
||||
TextEntry::make('error_message')->columnSpanFull(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BazaarApiRequests\Tables;
|
||||
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\TernaryFilter;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class BazaarApiRequestsTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('operation')->badge()->searchable()->sortable(),
|
||||
TextColumn::make('method')->badge(),
|
||||
TextColumn::make('status_code')->label('Status')->sortable(),
|
||||
IconColumn::make('successful')->boolean(),
|
||||
TextColumn::make('duration_ms')->label('Duration')->suffix(' ms')->sortable(),
|
||||
TextColumn::make('created_at')->since()->sortable(),
|
||||
])
|
||||
->filters([
|
||||
TernaryFilter::make('successful'),
|
||||
])
|
||||
->recordActions([
|
||||
ViewAction::make(),
|
||||
])
|
||||
->defaultSort('created_at', 'desc');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BazaarPurchases;
|
||||
|
||||
use App\Filament\Resources\BazaarPurchases\Pages\ListBazaarPurchases;
|
||||
use App\Filament\Resources\BazaarPurchases\Pages\ViewBazaarPurchase;
|
||||
use App\Filament\Resources\BazaarPurchases\Schemas\BazaarPurchaseForm;
|
||||
use App\Filament\Resources\BazaarPurchases\Schemas\BazaarPurchaseInfolist;
|
||||
use App\Filament\Resources\BazaarPurchases\Tables\BazaarPurchasesTable;
|
||||
use App\Models\BazaarPurchase;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
use UnitEnum;
|
||||
|
||||
class BazaarPurchaseResource extends Resource
|
||||
{
|
||||
protected static ?string $model = BazaarPurchase::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleStack;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Cafe Bazaar';
|
||||
|
||||
protected static ?string $navigationLabel = 'Purchases';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return BazaarPurchaseForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function infolist(Schema $schema): Schema
|
||||
{
|
||||
return BazaarPurchaseInfolist::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return BazaarPurchasesTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListBazaarPurchases::route('/'),
|
||||
'view' => ViewBazaarPurchase::route('/{record}'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BazaarPurchases\Pages;
|
||||
|
||||
use App\Filament\Resources\BazaarPurchases\BazaarPurchaseResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateBazaarPurchase extends CreateRecord
|
||||
{
|
||||
protected static string $resource = BazaarPurchaseResource::class;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BazaarPurchases\Pages;
|
||||
|
||||
use App\Filament\Resources\BazaarPurchases\BazaarPurchaseResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditBazaarPurchase extends EditRecord
|
||||
{
|
||||
protected static string $resource = BazaarPurchaseResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
ViewAction::make(),
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BazaarPurchases\Pages;
|
||||
|
||||
use App\Filament\Resources\BazaarPurchases\BazaarPurchaseResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListBazaarPurchases extends ListRecords
|
||||
{
|
||||
protected static string $resource = BazaarPurchaseResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BazaarPurchases\Pages;
|
||||
|
||||
use App\Filament\Resources\BazaarPurchases\BazaarPurchaseResource;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewBazaarPurchase extends ViewRecord
|
||||
{
|
||||
protected static string $resource = BazaarPurchaseResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BazaarPurchases\Schemas;
|
||||
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class BazaarPurchaseForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
//
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BazaarPurchases\Schemas;
|
||||
|
||||
use Filament\Infolists\Components\IconEntry;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class BazaarPurchaseInfolist
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextEntry::make('product_id'),
|
||||
TextEntry::make('purchase_token')->copyable()->columnSpanFull(),
|
||||
TextEntry::make('status')->badge(),
|
||||
IconEntry::make('is_consumed')->boolean(),
|
||||
TextEntry::make('purchased_at')->dateTime(),
|
||||
TextEntry::make('validated_at')->dateTime(),
|
||||
TextEntry::make('bazaar_response')->formatStateUsing(fn (?array $state): string => json_encode($state, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE))->columnSpanFull(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BazaarPurchases\Tables;
|
||||
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class BazaarPurchasesTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('product_id')->searchable()->sortable(),
|
||||
TextColumn::make('status')->badge()->sortable(),
|
||||
IconColumn::make('is_consumed')->boolean(),
|
||||
TextColumn::make('purchased_at')->dateTime()->sortable(),
|
||||
TextColumn::make('validated_at')->since()->sortable(),
|
||||
])
|
||||
->filters([
|
||||
SelectFilter::make('status')->options([
|
||||
'purchased' => 'Purchased',
|
||||
'refunded' => 'Refunded',
|
||||
'unknown' => 'Unknown',
|
||||
]),
|
||||
])
|
||||
->recordActions([
|
||||
ViewAction::make(),
|
||||
])
|
||||
->defaultSort('created_at', 'desc');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BazaarReleases;
|
||||
|
||||
use App\Filament\Resources\BazaarReleases\Pages\ListBazaarReleases;
|
||||
use App\Filament\Resources\BazaarReleases\Pages\ViewBazaarRelease;
|
||||
use App\Filament\Resources\BazaarReleases\Schemas\BazaarReleaseForm;
|
||||
use App\Filament\Resources\BazaarReleases\Schemas\BazaarReleaseInfolist;
|
||||
use App\Filament\Resources\BazaarReleases\Tables\BazaarReleasesTable;
|
||||
use App\Models\BazaarRelease;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
use UnitEnum;
|
||||
|
||||
class BazaarReleaseResource extends Resource
|
||||
{
|
||||
protected static ?string $model = BazaarRelease::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleStack;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Cafe Bazaar';
|
||||
|
||||
protected static ?string $navigationLabel = 'Publishing';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return BazaarReleaseForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function infolist(Schema $schema): Schema
|
||||
{
|
||||
return BazaarReleaseInfolist::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return BazaarReleasesTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListBazaarReleases::route('/'),
|
||||
'view' => ViewBazaarRelease::route('/{record}'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BazaarReleases\Pages;
|
||||
|
||||
use App\Filament\Resources\BazaarReleases\BazaarReleaseResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateBazaarRelease extends CreateRecord
|
||||
{
|
||||
protected static string $resource = BazaarReleaseResource::class;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BazaarReleases\Pages;
|
||||
|
||||
use App\Filament\Resources\BazaarReleases\BazaarReleaseResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditBazaarRelease extends EditRecord
|
||||
{
|
||||
protected static string $resource = BazaarReleaseResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
ViewAction::make(),
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BazaarReleases\Pages;
|
||||
|
||||
use App\Filament\Resources\BazaarReleases\BazaarReleaseResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListBazaarReleases extends ListRecords
|
||||
{
|
||||
protected static string $resource = BazaarReleaseResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BazaarReleases\Pages;
|
||||
|
||||
use App\Filament\Resources\BazaarReleases\BazaarReleaseResource;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewBazaarRelease extends ViewRecord
|
||||
{
|
||||
protected static string $resource = BazaarReleaseResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BazaarReleases\Schemas;
|
||||
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class BazaarReleaseForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
//
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BazaarReleases\Schemas;
|
||||
|
||||
use Filament\Infolists\Components\IconEntry;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class BazaarReleaseInfolist
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextEntry::make('bazaar_release_id')->label('Bazaar release ID'),
|
||||
TextEntry::make('status')->badge(),
|
||||
TextEntry::make('artifact_type')->badge(),
|
||||
TextEntry::make('staged_rollout_percentage')->suffix('%'),
|
||||
IconEntry::make('auto_publish')->boolean(),
|
||||
TextEntry::make('changelog_fa')->columnSpanFull(),
|
||||
TextEntry::make('changelog_en')->columnSpanFull(),
|
||||
TextEntry::make('developer_note')->columnSpanFull(),
|
||||
TextEntry::make('bazaar_response')->formatStateUsing(fn (?array $state): string => json_encode($state, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE))->columnSpanFull(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BazaarReleases\Tables;
|
||||
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class BazaarReleasesTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('bazaar_release_id')->label('Bazaar ID')->sortable(),
|
||||
TextColumn::make('status')->badge()->sortable(),
|
||||
TextColumn::make('artifact_type')->badge(),
|
||||
TextColumn::make('staged_rollout_percentage')->suffix('%')->sortable(),
|
||||
IconColumn::make('auto_publish')->boolean(),
|
||||
TextColumn::make('committed_at')->dateTime()->sortable(),
|
||||
TextColumn::make('published_at')->dateTime()->sortable(),
|
||||
])
|
||||
->filters([
|
||||
SelectFilter::make('status')->options([
|
||||
'draft' => 'Draft',
|
||||
'awaiting_bin' => 'Awaiting BIN',
|
||||
'processing_bundle' => 'Processing bundle',
|
||||
'artifact_uploaded' => 'Artifact uploaded',
|
||||
'committed' => 'Committed',
|
||||
'published' => 'Published',
|
||||
'deleted' => 'Deleted',
|
||||
]),
|
||||
])
|
||||
->recordActions([
|
||||
ViewAction::make(),
|
||||
])
|
||||
->defaultSort('created_at', 'desc');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BazaarReviews;
|
||||
|
||||
use App\Filament\Resources\BazaarReviews\Pages\ListBazaarReviews;
|
||||
use App\Filament\Resources\BazaarReviews\Pages\ViewBazaarReview;
|
||||
use App\Filament\Resources\BazaarReviews\Schemas\BazaarReviewForm;
|
||||
use App\Filament\Resources\BazaarReviews\Schemas\BazaarReviewInfolist;
|
||||
use App\Filament\Resources\BazaarReviews\Tables\BazaarReviewsTable;
|
||||
use App\Models\BazaarReview;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
use UnitEnum;
|
||||
|
||||
class BazaarReviewResource extends Resource
|
||||
{
|
||||
protected static ?string $model = BazaarReview::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleStack;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Cafe Bazaar';
|
||||
|
||||
protected static ?string $navigationLabel = 'Reviews';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return BazaarReviewForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function infolist(Schema $schema): Schema
|
||||
{
|
||||
return BazaarReviewInfolist::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return BazaarReviewsTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListBazaarReviews::route('/'),
|
||||
'view' => ViewBazaarReview::route('/{record}'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BazaarReviews\Pages;
|
||||
|
||||
use App\Filament\Resources\BazaarReviews\BazaarReviewResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateBazaarReview extends CreateRecord
|
||||
{
|
||||
protected static string $resource = BazaarReviewResource::class;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BazaarReviews\Pages;
|
||||
|
||||
use App\Filament\Resources\BazaarReviews\BazaarReviewResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditBazaarReview extends EditRecord
|
||||
{
|
||||
protected static string $resource = BazaarReviewResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
ViewAction::make(),
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BazaarReviews\Pages;
|
||||
|
||||
use App\Filament\Resources\BazaarReviews\BazaarReviewResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListBazaarReviews extends ListRecords
|
||||
{
|
||||
protected static string $resource = BazaarReviewResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BazaarReviews\Pages;
|
||||
|
||||
use App\Filament\Resources\BazaarReviews\BazaarReviewResource;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewBazaarReview extends ViewRecord
|
||||
{
|
||||
protected static string $resource = BazaarReviewResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BazaarReviews\Schemas;
|
||||
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class BazaarReviewForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
//
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BazaarReviews\Schemas;
|
||||
|
||||
use Filament\Infolists\Components\IconEntry;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class BazaarReviewInfolist
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextEntry::make('bazaar_review_id')->label('Bazaar review ID'),
|
||||
TextEntry::make('rate')->badge(),
|
||||
TextEntry::make('text')->columnSpanFull(),
|
||||
TextEntry::make('app_version_code'),
|
||||
IconEntry::make('is_edited')->boolean(),
|
||||
TextEntry::make('published_at')->dateTime(),
|
||||
TextEntry::make('developer_reply_text')->columnSpanFull(),
|
||||
TextEntry::make('developer_reply_email'),
|
||||
TextEntry::make('developer_replied_at')->dateTime(),
|
||||
TextEntry::make('bazaar_response')->formatStateUsing(fn (?array $state): string => json_encode($state, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE))->columnSpanFull(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BazaarReviews\Tables;
|
||||
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class BazaarReviewsTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('rate')->badge()->sortable(),
|
||||
TextColumn::make('text')->limit(70)->searchable()->wrap(),
|
||||
TextColumn::make('app_version_code')->label('App version')->sortable(),
|
||||
IconColumn::make('replied')->label('Replied')->state(fn ($record): bool => filled($record->developer_reply_text))->boolean(),
|
||||
TextColumn::make('published_at')->dateTime()->sortable(),
|
||||
])
|
||||
->filters([
|
||||
SelectFilter::make('rate')->options([1 => '1 star', 2 => '2 stars', 3 => '3 stars', 4 => '4 stars', 5 => '5 stars']),
|
||||
])
|
||||
->recordActions([
|
||||
ViewAction::make(),
|
||||
])
|
||||
->defaultSort('published_at', 'desc');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BazaarSubscriptions;
|
||||
|
||||
use App\Filament\Resources\BazaarSubscriptions\Pages\ListBazaarSubscriptions;
|
||||
use App\Filament\Resources\BazaarSubscriptions\Pages\ViewBazaarSubscription;
|
||||
use App\Filament\Resources\BazaarSubscriptions\Schemas\BazaarSubscriptionForm;
|
||||
use App\Filament\Resources\BazaarSubscriptions\Schemas\BazaarSubscriptionInfolist;
|
||||
use App\Filament\Resources\BazaarSubscriptions\Tables\BazaarSubscriptionsTable;
|
||||
use App\Models\BazaarSubscription;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
use UnitEnum;
|
||||
|
||||
class BazaarSubscriptionResource extends Resource
|
||||
{
|
||||
protected static ?string $model = BazaarSubscription::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleStack;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Cafe Bazaar';
|
||||
|
||||
protected static ?string $navigationLabel = 'Subscriptions';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return BazaarSubscriptionForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function infolist(Schema $schema): Schema
|
||||
{
|
||||
return BazaarSubscriptionInfolist::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return BazaarSubscriptionsTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListBazaarSubscriptions::route('/'),
|
||||
'view' => ViewBazaarSubscription::route('/{record}'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BazaarSubscriptions\Pages;
|
||||
|
||||
use App\Filament\Resources\BazaarSubscriptions\BazaarSubscriptionResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateBazaarSubscription extends CreateRecord
|
||||
{
|
||||
protected static string $resource = BazaarSubscriptionResource::class;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BazaarSubscriptions\Pages;
|
||||
|
||||
use App\Filament\Resources\BazaarSubscriptions\BazaarSubscriptionResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditBazaarSubscription extends EditRecord
|
||||
{
|
||||
protected static string $resource = BazaarSubscriptionResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
ViewAction::make(),
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BazaarSubscriptions\Pages;
|
||||
|
||||
use App\Filament\Resources\BazaarSubscriptions\BazaarSubscriptionResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListBazaarSubscriptions extends ListRecords
|
||||
{
|
||||
protected static string $resource = BazaarSubscriptionResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BazaarSubscriptions\Pages;
|
||||
|
||||
use App\Filament\Resources\BazaarSubscriptions\BazaarSubscriptionResource;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewBazaarSubscription extends ViewRecord
|
||||
{
|
||||
protected static string $resource = BazaarSubscriptionResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BazaarSubscriptions\Schemas;
|
||||
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class BazaarSubscriptionForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
//
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BazaarSubscriptions\Schemas;
|
||||
|
||||
use Filament\Infolists\Components\IconEntry;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class BazaarSubscriptionInfolist
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextEntry::make('subscription_id'),
|
||||
TextEntry::make('purchase_token')->copyable()->columnSpanFull(),
|
||||
TextEntry::make('linked_subscription_token')->copyable()->columnSpanFull(),
|
||||
TextEntry::make('status')->badge(),
|
||||
IconEntry::make('auto_renewing')->boolean(),
|
||||
TextEntry::make('starts_at')->dateTime(),
|
||||
TextEntry::make('valid_until')->dateTime(),
|
||||
TextEntry::make('bazaar_response')->formatStateUsing(fn (?array $state): string => json_encode($state, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE))->columnSpanFull(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BazaarSubscriptions\Tables;
|
||||
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class BazaarSubscriptionsTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('subscription_id')->searchable()->sortable(),
|
||||
TextColumn::make('status')->badge()->sortable(),
|
||||
IconColumn::make('auto_renewing')->boolean(),
|
||||
TextColumn::make('starts_at')->dateTime()->sortable(),
|
||||
TextColumn::make('valid_until')->dateTime()->sortable(),
|
||||
TextColumn::make('validated_at')->since()->sortable(),
|
||||
])
|
||||
->filters([
|
||||
SelectFilter::make('status')->options([
|
||||
'active' => 'Active',
|
||||
'expired' => 'Expired',
|
||||
'cancelled' => 'Cancelled',
|
||||
'refunded' => 'Refunded',
|
||||
'unknown' => 'Unknown',
|
||||
]),
|
||||
])
|
||||
->recordActions([
|
||||
ViewAction::make(),
|
||||
])
|
||||
->defaultSort('created_at', 'desc');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Models\MobileApp;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Widgets\StatsOverviewWidget;
|
||||
use Filament\Widgets\StatsOverviewWidget\Stat;
|
||||
|
||||
class AppOverview extends StatsOverviewWidget
|
||||
{
|
||||
protected function getStats(): array
|
||||
{
|
||||
/** @var MobileApp $app */
|
||||
$app = Filament::getTenant();
|
||||
$apiRequestCount = $app->bazaarApiRequests()->count();
|
||||
$successRate = $apiRequestCount === 0
|
||||
? '—'
|
||||
: round($app->bazaarApiRequests()->where('successful', true)->count() / $apiRequestCount * 100, 1).'%';
|
||||
|
||||
return [
|
||||
Stat::make('Bazaar sync', ucfirst($app->bazaar_sync_status))
|
||||
->description($app->bazaar_last_synced_at?->diffForHumans() ?? 'Never synchronized'),
|
||||
Stat::make('Validated purchases', $app->bazaarPurchases()->count()),
|
||||
Stat::make('Active subscriptions', $app->bazaarSubscriptions()->where('status', 'active')->count()),
|
||||
Stat::make('Reviews', $app->bazaarReviews()->count()),
|
||||
Stat::make('Bazaar API success rate', $successRate),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user