Refactor VisaMasterPaymentOrderInfolist and SpatieMediaLibraryFileEntry components
- Cleaned up imports and improved code formatting for better readability. - Adjusted layout in VisaMasterPaymentOrderInfolist schema for consistent column spans. - Enhanced SpatieMediaLibraryFileEntry component by streamlining property definitions and ensuring consistent formatting.
This commit is contained in:
@@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
namespace App\Filament\Clusters\VisaMasterPayments\Resources\VisaMasterPaymentOrders\Schemas;
|
namespace App\Filament\Clusters\VisaMasterPayments\Resources\VisaMasterPaymentOrders\Schemas;
|
||||||
|
|
||||||
|
use App\Filament\Infolists\Components\SpatieMediaLibraryFileEntry;
|
||||||
use App\Modules\OrderStatus\Repositories\OrderStatusRepository;
|
use App\Modules\OrderStatus\Repositories\OrderStatusRepository;
|
||||||
use App\Modules\Region\Repositories\RegionRepository;
|
use App\Modules\Region\Repositories\RegionRepository;
|
||||||
use App\Modules\TurkmenPassport\Repositories\TurkmenPassportRepository;
|
use App\Modules\TurkmenPassport\Repositories\TurkmenPassportRepository;
|
||||||
use App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrder;
|
use App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrder;
|
||||||
use Filament\Infolists\Components\IconEntry;
|
use Filament\Infolists\Components\IconEntry;
|
||||||
use App\Filament\Infolists\Components\SpatieMediaLibraryFileEntry;
|
|
||||||
use Filament\Infolists\Components\TextEntry;
|
use Filament\Infolists\Components\TextEntry;
|
||||||
use Filament\Schemas\Components\Fieldset;
|
use Filament\Schemas\Components\Fieldset;
|
||||||
use Filament\Schemas\Components\Section;
|
use Filament\Schemas\Components\Section;
|
||||||
@@ -15,10 +15,7 @@ use Filament\Schemas\Components\Tabs;
|
|||||||
use Filament\Schemas\Components\Tabs\Tab;
|
use Filament\Schemas\Components\Tabs\Tab;
|
||||||
use Filament\Schemas\Schema;
|
use Filament\Schemas\Schema;
|
||||||
use Filament\Support\Icons\Heroicon;
|
use Filament\Support\Icons\Heroicon;
|
||||||
use Hugomyb\FilamentMediaAction\Actions\MediaAction;
|
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use RalphJSmit\Filament\Upload\Filament\Forms\Components\AdvancedFileUpload;
|
|
||||||
use RalphJSmit\Filament\Upload\Filament\Infolists\Entries\PdfEntry;
|
|
||||||
|
|
||||||
class VisaMasterPaymentOrderInfolist
|
class VisaMasterPaymentOrderInfolist
|
||||||
{
|
{
|
||||||
@@ -78,35 +75,35 @@ class VisaMasterPaymentOrderInfolist
|
|||||||
->columns(8)
|
->columns(8)
|
||||||
->schema([
|
->schema([
|
||||||
TextEntry::make('sender_full_name')
|
TextEntry::make('sender_full_name')
|
||||||
->label(__('Name, Surname, Patronic name'))
|
->label(__('Name, Surname, Patronic name'))
|
||||||
->columnSpan(4)
|
->columnSpan(4)
|
||||||
->placeholder('-'),
|
->placeholder('-'),
|
||||||
|
|
||||||
TextEntry::make('sender_passport')
|
TextEntry::make('sender_passport')
|
||||||
->label(__('Passport serie and number'))
|
->label(__('Passport serie and number'))
|
||||||
->formatStateUsing(function ($record) {
|
->formatStateUsing(function ($record) {
|
||||||
$serie = TurkmenPassportRepository::values()[$record->sender_passport_serie] ?? $record->sender_passport_serie;
|
$serie = TurkmenPassportRepository::values()[$record->sender_passport_serie] ?? $record->sender_passport_serie;
|
||||||
|
|
||||||
return $serie.' '.$record->sender_passport_number;
|
return $serie.' '.$record->sender_passport_number;
|
||||||
})
|
})
|
||||||
->columnSpan(2)
|
->columnSpan(2)
|
||||||
->placeholder('-'),
|
->placeholder('-'),
|
||||||
|
|
||||||
TextEntry::make('phone')
|
TextEntry::make('phone')
|
||||||
->label(__('Phone'))
|
->label(__('Phone'))
|
||||||
->formatStateUsing(fn ($state) => '+993 '.$state)
|
->formatStateUsing(fn ($state) => '+993 '.$state)
|
||||||
->columnSpan(2)
|
->columnSpan(2)
|
||||||
->placeholder('-'),
|
->placeholder('-'),
|
||||||
|
|
||||||
TextEntry::make('sender_deposit_account')
|
TextEntry::make('sender_deposit_account')
|
||||||
->label(__('Deposit account'))
|
->label(__('Deposit account'))
|
||||||
->columnSpan(4)
|
->columnSpan(4)
|
||||||
->placeholder('-'),
|
->placeholder('-'),
|
||||||
|
|
||||||
TextEntry::make('address')
|
TextEntry::make('address')
|
||||||
->label(__('Address'))
|
->label(__('Address'))
|
||||||
->columnSpan(4)
|
->columnSpan(4)
|
||||||
->placeholder('-'),
|
->placeholder('-'),
|
||||||
]),
|
]),
|
||||||
|
|
||||||
Section::make(__('Files'))
|
Section::make(__('Files'))
|
||||||
@@ -117,7 +114,7 @@ class VisaMasterPaymentOrderInfolist
|
|||||||
SpatieMediaLibraryFileEntry::make('sender_passport_local')
|
SpatieMediaLibraryFileEntry::make('sender_passport_local')
|
||||||
->collection('sender_passport_local')
|
->collection('sender_passport_local')
|
||||||
->label(__('Ugradyja degişli Türkmenistanyň raýatynyň (içki milli) pasportynyň asyl görnüşi we göçürmesi')),
|
->label(__('Ugradyja degişli Türkmenistanyň raýatynyň (içki milli) pasportynyň asyl görnüşi we göçürmesi')),
|
||||||
|
|
||||||
SpatieMediaLibraryFileEntry::make('sender_passport_international')
|
SpatieMediaLibraryFileEntry::make('sender_passport_international')
|
||||||
->collection('sender_passport_international')
|
->collection('sender_passport_international')
|
||||||
->label(__('Ugradyja degişli Türkmenistandan çykmak we Türkmenistana girmek üçin pasportynyň asyl görnüşi we göçürmesi')),
|
->label(__('Ugradyja degişli Türkmenistandan çykmak we Türkmenistana girmek üçin pasportynyň asyl görnüşi we göçürmesi')),
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
namespace App\Filament\Infolists\Components;
|
namespace App\Filament\Infolists\Components;
|
||||||
|
|
||||||
use Closure;
|
use Closure;
|
||||||
use Filament\Infolists\Components\Entry;
|
|
||||||
use Filament\Actions\Action;
|
use Filament\Actions\Action;
|
||||||
|
use Filament\Infolists\Components\Entry;
|
||||||
use Filament\Support\Concerns\HasMediaFilter;
|
use Filament\Support\Concerns\HasMediaFilter;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
@@ -19,7 +19,7 @@ class SpatieMediaLibraryFileEntry extends Entry
|
|||||||
|
|
||||||
public function getViewMediaActionName(): string
|
public function getViewMediaActionName(): string
|
||||||
{
|
{
|
||||||
return 'view_media_' . $this->getName();
|
return 'view_media_'.$this->getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
@@ -38,45 +38,45 @@ class SpatieMediaLibraryFileEntry extends Entry
|
|||||||
|
|
||||||
protected string $view = 'filament.infolists.components.spatie-media-library-file-entry';
|
protected string $view = 'filament.infolists.components.spatie-media-library-file-entry';
|
||||||
|
|
||||||
protected string | Closure | null $collection = null;
|
protected string|Closure|null $collection = null;
|
||||||
|
|
||||||
protected string | Closure | null $conversion = null;
|
protected string|Closure|null $conversion = null;
|
||||||
|
|
||||||
protected string | Closure $visibility = 'private';
|
protected string|Closure $visibility = 'private';
|
||||||
|
|
||||||
protected bool | Closure $isDownloadable = true;
|
protected bool|Closure $isDownloadable = true;
|
||||||
|
|
||||||
protected bool | Closure $isPreviewable = true;
|
|
||||||
|
|
||||||
public function collection(string | Closure | null $collection): static
|
protected bool|Closure $isPreviewable = true;
|
||||||
|
|
||||||
|
public function collection(string|Closure|null $collection): static
|
||||||
{
|
{
|
||||||
$this->collection = $collection;
|
$this->collection = $collection;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function conversion(string | Closure | null $conversion): static
|
public function conversion(string|Closure|null $conversion): static
|
||||||
{
|
{
|
||||||
$this->conversion = $conversion;
|
$this->conversion = $conversion;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function visibility(string | Closure $visibility): static
|
public function visibility(string|Closure $visibility): static
|
||||||
{
|
{
|
||||||
$this->visibility = $visibility;
|
$this->visibility = $visibility;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function downloadable(bool | Closure $condition = true): static
|
public function downloadable(bool|Closure $condition = true): static
|
||||||
{
|
{
|
||||||
$this->isDownloadable = $condition;
|
$this->isDownloadable = $condition;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function previewable(bool | Closure $condition = true): static
|
public function previewable(bool|Closure $condition = true): static
|
||||||
{
|
{
|
||||||
$this->isPreviewable = $condition;
|
$this->isPreviewable = $condition;
|
||||||
|
|
||||||
@@ -97,12 +97,12 @@ class SpatieMediaLibraryFileEntry extends Entry
|
|||||||
{
|
{
|
||||||
return (string) $this->evaluate($this->visibility);
|
return (string) $this->evaluate($this->visibility);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isDownloadable(): bool
|
public function isDownloadable(): bool
|
||||||
{
|
{
|
||||||
return (bool) $this->evaluate($this->isDownloadable);
|
return (bool) $this->evaluate($this->isDownloadable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isPreviewable(): bool
|
public function isPreviewable(): bool
|
||||||
{
|
{
|
||||||
return (bool) $this->evaluate($this->isPreviewable);
|
return (bool) $this->evaluate($this->isPreviewable);
|
||||||
@@ -137,7 +137,7 @@ class SpatieMediaLibraryFileEntry extends Entry
|
|||||||
}
|
}
|
||||||
|
|
||||||
$records = Arr::wrap($record);
|
$records = Arr::wrap($record);
|
||||||
|
|
||||||
$allMedia = collect([]);
|
$allMedia = collect([]);
|
||||||
|
|
||||||
$collection = $this->getCollection() ?? 'default';
|
$collection = $this->getCollection() ?? 'default';
|
||||||
@@ -145,7 +145,7 @@ class SpatieMediaLibraryFileEntry extends Entry
|
|||||||
foreach ($records as $record) {
|
foreach ($records as $record) {
|
||||||
/** @var Model $record */
|
/** @var Model $record */
|
||||||
$media = $record->getRelationValue('media');
|
$media = $record->getRelationValue('media');
|
||||||
|
|
||||||
if (! $media) {
|
if (! $media) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -160,7 +160,7 @@ class SpatieMediaLibraryFileEntry extends Entry
|
|||||||
fn (Collection $media) => $this->filterMedia($media)
|
fn (Collection $media) => $this->filterMedia($media)
|
||||||
)
|
)
|
||||||
->sortBy('order_column');
|
->sortBy('order_column');
|
||||||
|
|
||||||
$allMedia = $allMedia->merge($filteredMedia);
|
$allMedia = $allMedia->merge($filteredMedia);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ class WorkPanelProvider extends PanelProvider
|
|||||||
->customProfileComponents([
|
->customProfileComponents([
|
||||||
UserProfileFields::class,
|
UserProfileFields::class,
|
||||||
]),
|
]),
|
||||||
|
|
||||||
// FilamentUpload::make(),
|
// FilamentUpload::make(),
|
||||||
])
|
])
|
||||||
->authMiddleware([
|
->authMiddleware([
|
||||||
|
|||||||
Reference in New Issue
Block a user