-
Notifications
You must be signed in to change notification settings - Fork 5
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
Showing
177 changed files
with
3,009 additions
and
1,398 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
/public/hot | ||
/public/storage | ||
/storage/*.key | ||
/storage/**/*.log | ||
/vendor | ||
.env | ||
.env.backup | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Filament\Resources; | ||
|
||
use App\Filament\Resources\GalleryResource\Pages\ListGalleries; | ||
use App\Models\Gallery; | ||
use Filament\Forms\Form; | ||
use Filament\Resources\Resource; | ||
use Filament\Tables\Actions\Action; | ||
use Filament\Tables\Actions\ActionGroup; | ||
use Filament\Tables\Actions\DeleteAction; | ||
use Filament\Tables\Columns\ImageColumn; | ||
use Filament\Tables\Columns\TextColumn; | ||
use Filament\Tables\Table; | ||
|
||
class GalleryResource extends Resource | ||
{ | ||
protected static ?string $model = Gallery::class; | ||
|
||
protected static ?string $navigationIcon = 'heroicon-o-photo'; | ||
|
||
public static function form(Form $form): Form | ||
{ | ||
return $form | ||
->schema([ | ||
// | ||
]); | ||
} | ||
|
||
public static function table(Table $table): Table | ||
{ | ||
return $table | ||
->columns([ | ||
ImageColumn::make('cover_image') | ||
->getStateUsing(fn (Gallery $gallery) => $gallery->cover_image ? str_replace('/storage', '', $gallery->cover_image) : null) | ||
->disk('public') | ||
->size(40) | ||
->url(fn (Gallery $gallery) => $gallery->cover_image) | ||
->openUrlInNewTab(), | ||
|
||
TextColumn::make('name') | ||
->weight('medium') | ||
->color('primary') | ||
->label('Name') | ||
->default('Unknown') | ||
->url(fn (Gallery $gallery) => route('galleries.view', $gallery)) | ||
->icon(fn ($state) => $state ? 'heroicon-o-arrow-top-right-on-square' : null) | ||
->iconPosition('after') | ||
->openUrlInNewTab() | ||
->sortable(), | ||
|
||
TextColumn::make('created_at') | ||
->label('Date Created') | ||
->dateTime() | ||
->icon('heroicon-m-calendar') | ||
->sortable(), | ||
]) | ||
->filters([ | ||
// | ||
]) | ||
->actions([ | ||
ActionGroup::make([ | ||
Action::make('unresolve') | ||
->label('Remove cover image') | ||
->requiresConfirmation() | ||
->action(fn (Gallery $gallery) => $gallery->update([ | ||
'cover_image' => null, | ||
])) | ||
->icon('heroicon-o-photo') | ||
->modalHeading('Remove cover image') | ||
->modalDescription('Are you sure you want to remove the cover image for this gallery?') | ||
->modalSubmitActionLabel('Yes, do it') | ||
->modalIcon('heroicon-o-photo') | ||
->modalWidth('sm'), | ||
|
||
DeleteAction::make(), | ||
]), | ||
]); | ||
} | ||
|
||
public static function getRelations(): array | ||
{ | ||
return [ | ||
// | ||
]; | ||
} | ||
|
||
public static function getPages(): array | ||
{ | ||
return [ | ||
'index' => ListGalleries::route('/'), | ||
]; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
app/Filament/Resources/GalleryResource/Pages/ListGalleries.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,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Filament\Resources\GalleryResource\Pages; | ||
|
||
use App\Filament\Resources\GalleryResource; | ||
use Filament\Resources\Pages\ListRecords; | ||
|
||
class ListGalleries extends ListRecords | ||
{ | ||
protected static string $resource = GalleryResource::class; | ||
|
||
protected function getHeaderActions(): array | ||
{ | ||
return [ | ||
// | ||
]; | ||
} | ||
} |
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,85 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Filament\Widgets; | ||
|
||
use App\Models\Collection; | ||
use App\Models\Nft; | ||
use App\Models\Wallet; | ||
use Filament\Widgets\StatsOverviewWidget; | ||
use Filament\Widgets\StatsOverviewWidget\Stat; | ||
use Illuminate\Support\Facades\Cache; | ||
use Illuminate\Support\Facades\DB; | ||
|
||
class OverviewStats extends StatsOverviewWidget | ||
{ | ||
protected function getCards(): array | ||
{ | ||
$ttl = now()->addHours(1); | ||
|
||
return [ | ||
Stat::make('Number of Wallets', static fn () => Cache::remember('filament:widgets:wallets', $ttl, static fn () => number_format(Wallet::count()))), | ||
|
||
Stat::make('Number of NFTs', static fn () => Cache::remember('filament:widgets:nfts', $ttl, static fn () => number_format(Nft::count()))), | ||
|
||
Stat::make('Number of wallet-owned NFTs', static fn () => Cache::remember('filament:widgets:owned-nfts', $ttl, static fn () => number_format(Nft::whereNotNull('wallet_id')->count()))), | ||
|
||
Stat::make('Number of collections', static fn () => Cache::remember('filament:widgets:collections', $ttl, | ||
static function () { | ||
return Collection::count(); | ||
} | ||
)), | ||
|
||
Stat::make('Number of collections for wallet-owned NFTs', static fn () => Cache::remember('filament:widgets:collections-owned-nfts', $ttl, | ||
static function () { | ||
return Nft::whereNotNull('wallet_id')->distinct('collection_id')->count(); | ||
} | ||
)), | ||
|
||
Stat::make('Average NFTs per wallet', static fn () => Cache::remember('filament:widgets:nfts-per-wallet', $ttl, | ||
static function () { | ||
$wallets = Wallet::count(); | ||
|
||
if ($wallets === 0) { | ||
return 0; | ||
} | ||
|
||
return round(Nft::whereNotNull('wallet_id')->count() / $wallets, 2); | ||
} | ||
)), | ||
|
||
Stat::make('Average collections per wallet', static fn () => Cache::remember('filament:widgets:collections-per-wallet', $ttl, | ||
static function () { | ||
$wallets = Wallet::count(); | ||
|
||
if ($wallets === 0) { | ||
return 0; | ||
} | ||
|
||
return round(Collection::count() / $wallets, 2); | ||
} | ||
)), | ||
|
||
Stat::make('Most NFTs in a wallet', static fn () => Cache::remember('filament:widgets:most-nfts', $ttl, | ||
static function () { | ||
return Wallet::withCount('nfts')->latest('nfts_count')->first()->nfts_count; | ||
} | ||
))->description('Number of NFTs for a wallet that owns the most NFTs'), | ||
|
||
Stat::make('Most unique collections owned by wallet', static fn () => Cache::remember('filament:widgets:most-collections', $ttl, | ||
static function () { | ||
|
||
/** @var object{wallet_id: int, count: int} $result */ | ||
$result = DB::table('nfts') | ||
->select(DB::raw('nfts.wallet_id, count(distinct(collection_id))')) | ||
->groupBy('wallet_id') | ||
->limit(1) | ||
->first(); | ||
|
||
return $result->count; | ||
} | ||
))->description('Number of collections for a wallet that owns NFTs in the most collections'), | ||
]; | ||
} | ||
} |
Oops, something went wrong.