feat: integrate Spotify API for syncing music productions with new command and UI components
This commit is contained in:
@@ -2,9 +2,14 @@
|
||||
|
||||
namespace App\Filament\Admin\Resources\MusicProductions\Pages;
|
||||
|
||||
use App\Console\Commands\SyncSpotifyMusicProductions;
|
||||
use App\Filament\Admin\Resources\MusicProductions\MusicProductionResource;
|
||||
use App\Services\SpotifyService;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
class ListMusicProductions extends ListRecords
|
||||
{
|
||||
@@ -18,6 +23,31 @@ class ListMusicProductions extends ListRecords
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('syncSpotify')
|
||||
->label(__('music_productions.sync_spotify'))
|
||||
->icon('heroicon-o-arrow-path')
|
||||
->color('success')
|
||||
->requiresConfirmation()
|
||||
->modalHeading(__('music_productions.sync_spotify_heading'))
|
||||
->modalDescription(__('music_productions.sync_spotify_description'))
|
||||
->visible(fn (): bool => app(SpotifyService::class)->isConfigured())
|
||||
->action(function (): void {
|
||||
$exitCode = Artisan::call(SyncSpotifyMusicProductions::class);
|
||||
|
||||
if ($exitCode !== 0) {
|
||||
Notification::make()
|
||||
->title(__('music_productions.spotify_sync_failed'))
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Notification::make()
|
||||
->title(__('music_productions.spotify_sync_success'))
|
||||
->success()
|
||||
->send();
|
||||
}),
|
||||
CreateAction::make()
|
||||
->label(__('music_productions.create')),
|
||||
];
|
||||
|
||||
@@ -3,13 +3,16 @@
|
||||
namespace App\Filament\Admin\Resources\MusicProductions\Schemas;
|
||||
|
||||
use App\Filament\Admin\Resources\Components\TranslationTabs;
|
||||
use App\Models\MusicProduction;
|
||||
use Filament\Forms\Components\Checkbox;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\RichEditor;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Placeholder;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class MusicProductionForm
|
||||
{
|
||||
@@ -30,7 +33,7 @@ class MusicProductionForm
|
||||
if ($operation !== 'create') {
|
||||
return;
|
||||
}
|
||||
$set('slug', \Str::slug($state));
|
||||
$set('slug', Str::slug($state));
|
||||
}),
|
||||
|
||||
TextInput::make('slug')
|
||||
@@ -93,6 +96,33 @@ class MusicProductionForm
|
||||
])
|
||||
->columnSpan(1)
|
||||
->collapsible(false),
|
||||
|
||||
Section::make(__('music_productions.spotify_section'))
|
||||
->schema([
|
||||
Placeholder::make('spotify_album_id_display')
|
||||
->label(__('music_productions.spotify_album_id_field'))
|
||||
->content(fn (?MusicProduction $record): string => $record?->spotify_album_id ?? '-'),
|
||||
|
||||
Placeholder::make('spotify_type_display')
|
||||
->label(__('music_productions.spotify_type_field'))
|
||||
->content(fn (?MusicProduction $record): string => $record?->spotify_type
|
||||
? __('music_productions.spotify_type_' . $record->spotify_type, [], $record->spotify_type)
|
||||
: '-'),
|
||||
|
||||
Placeholder::make('spotify_url_display')
|
||||
->label(__('music_productions.spotify_url_field'))
|
||||
->content(fn (?MusicProduction $record): string => $record?->spotify_url ?? '-'),
|
||||
|
||||
Placeholder::make('spotify_synced_at_display')
|
||||
->label(__('music_productions.spotify_synced_at_field'))
|
||||
->content(fn (?MusicProduction $record): string => $record?->spotify_synced_at
|
||||
?->timezone(config('app.timezone'))
|
||||
->format('d.m.Y H:i') ?? '-'),
|
||||
])
|
||||
->columnSpanFull()
|
||||
->collapsible(true)
|
||||
->collapsed(true)
|
||||
->visible(fn (?MusicProduction $record): bool => filled($record?->spotify_album_id)),
|
||||
|
||||
// Alt Kısım - Galeri Görselleri
|
||||
Section::make(__('music_productions.gallery_field'))
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Filament\Admin\Resources\MusicProductions\Tables;
|
||||
|
||||
use App\Models\MusicProduction;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
@@ -21,7 +22,7 @@ class MusicProductionsTable
|
||||
->columns([
|
||||
ImageColumn::make('cover_image')
|
||||
->label(__('music_productions.cover_image_field'))
|
||||
->disk('public')
|
||||
->getStateUsing(fn (MusicProduction $record): ?string => $record->cover_image_url)
|
||||
->square()
|
||||
->size(60),
|
||||
|
||||
@@ -47,6 +48,19 @@ class MusicProductionsTable
|
||||
->label(__('music_productions.table_production_date'))
|
||||
->date('d.m.Y')
|
||||
->sortable(),
|
||||
|
||||
TextColumn::make('spotify_type')
|
||||
->label(__('music_productions.spotify_type_field'))
|
||||
->badge()
|
||||
->formatStateUsing(fn (?string $state): string => filled($state)
|
||||
? __('music_productions.spotify_type_' . $state, [], $state)
|
||||
: '-')
|
||||
->color(fn (?string $state): string => match ($state) {
|
||||
'single' => 'info',
|
||||
'album' => 'success',
|
||||
default => 'gray',
|
||||
})
|
||||
->toggleable(),
|
||||
|
||||
ToggleColumn::make('is_active')
|
||||
->label(__('music_productions.table_is_active'))
|
||||
|
||||
Reference in New Issue
Block a user