Compare commits

...

3 Commits

Author SHA1 Message Date
Mekan1206
7111b1db09 Enhance SpatieMediaLibraryFileEntry component and update PHPStan configuration
- Added a new method to retrieve media for the entry in SpatieMediaLibraryFileEntry component.
- Updated PHPStan configuration to exclude the SpatieMediaLibraryFileEntry.php file from analysis.
2025-12-20 02:34:19 +05:00
Mekan1206
c4ee279d91 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.
2025-12-20 02:30:36 +05:00
Mekan1206
14c4ea5791 Update subNavigationPosition in CardsCluster to Top 2025-12-20 02:28:48 +05:00
5 changed files with 56 additions and 54 deletions

View File

@@ -13,7 +13,7 @@ class CardsCluster extends Cluster
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedCreditCard;
protected static ?SubNavigationPosition $subNavigationPosition = SubNavigationPosition::Start;
protected static ?SubNavigationPosition $subNavigationPosition = SubNavigationPosition::Top;
public static function getNavigationLabel(): string
{

View File

@@ -2,12 +2,12 @@
namespace App\Filament\Clusters\VisaMasterPayments\Resources\VisaMasterPaymentOrders\Schemas;
use App\Filament\Infolists\Components\SpatieMediaLibraryFileEntry;
use App\Modules\OrderStatus\Repositories\OrderStatusRepository;
use App\Modules\Region\Repositories\RegionRepository;
use App\Modules\TurkmenPassport\Repositories\TurkmenPassportRepository;
use App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrder;
use Filament\Infolists\Components\IconEntry;
use App\Filament\Infolists\Components\SpatieMediaLibraryFileEntry;
use Filament\Infolists\Components\TextEntry;
use Filament\Schemas\Components\Fieldset;
use Filament\Schemas\Components\Section;
@@ -15,10 +15,7 @@ use Filament\Schemas\Components\Tabs;
use Filament\Schemas\Components\Tabs\Tab;
use Filament\Schemas\Schema;
use Filament\Support\Icons\Heroicon;
use Hugomyb\FilamentMediaAction\Actions\MediaAction;
use Illuminate\Support\Str;
use RalphJSmit\Filament\Upload\Filament\Forms\Components\AdvancedFileUpload;
use RalphJSmit\Filament\Upload\Filament\Infolists\Entries\PdfEntry;
class VisaMasterPaymentOrderInfolist
{
@@ -78,35 +75,35 @@ class VisaMasterPaymentOrderInfolist
->columns(8)
->schema([
TextEntry::make('sender_full_name')
->label(__('Name, Surname, Patronic name'))
->columnSpan(4)
->placeholder('-'),
->label(__('Name, Surname, Patronic name'))
->columnSpan(4)
->placeholder('-'),
TextEntry::make('sender_passport')
->label(__('Passport serie and number'))
->formatStateUsing(function ($record) {
$serie = TurkmenPassportRepository::values()[$record->sender_passport_serie] ?? $record->sender_passport_serie;
TextEntry::make('sender_passport')
->label(__('Passport serie and number'))
->formatStateUsing(function ($record) {
$serie = TurkmenPassportRepository::values()[$record->sender_passport_serie] ?? $record->sender_passport_serie;
return $serie.' '.$record->sender_passport_number;
})
->columnSpan(2)
->placeholder('-'),
return $serie.' '.$record->sender_passport_number;
})
->columnSpan(2)
->placeholder('-'),
TextEntry::make('phone')
->label(__('Phone'))
->formatStateUsing(fn ($state) => '+993 '.$state)
->columnSpan(2)
->placeholder('-'),
TextEntry::make('phone')
->label(__('Phone'))
->formatStateUsing(fn ($state) => '+993 '.$state)
->columnSpan(2)
->placeholder('-'),
TextEntry::make('sender_deposit_account')
->label(__('Deposit account'))
->columnSpan(4)
->placeholder('-'),
TextEntry::make('sender_deposit_account')
->label(__('Deposit account'))
->columnSpan(4)
->placeholder('-'),
TextEntry::make('address')
->label(__('Address'))
->columnSpan(4)
->placeholder('-'),
TextEntry::make('address')
->label(__('Address'))
->columnSpan(4)
->placeholder('-'),
]),
Section::make(__('Files'))
@@ -117,7 +114,7 @@ class VisaMasterPaymentOrderInfolist
SpatieMediaLibraryFileEntry::make('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')),
SpatieMediaLibraryFileEntry::make('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')),

View File

@@ -3,8 +3,8 @@
namespace App\Filament\Infolists\Components;
use Closure;
use Filament\Infolists\Components\Entry;
use Filament\Actions\Action;
use Filament\Infolists\Components\Entry;
use Filament\Support\Concerns\HasMediaFilter;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Arr;
@@ -19,7 +19,7 @@ class SpatieMediaLibraryFileEntry extends Entry
public function getViewMediaActionName(): string
{
return 'view_media_' . $this->getName();
return 'view_media_'.$this->getName();
}
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 | 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 $isPreviewable = true;
protected bool|Closure $isDownloadable = 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;
return $this;
}
public function conversion(string | Closure | null $conversion): static
public function conversion(string|Closure|null $conversion): static
{
$this->conversion = $conversion;
return $this;
}
public function visibility(string | Closure $visibility): static
public function visibility(string|Closure $visibility): static
{
$this->visibility = $visibility;
return $this;
}
public function downloadable(bool | Closure $condition = true): static
public function downloadable(bool|Closure $condition = true): static
{
$this->isDownloadable = $condition;
return $this;
}
public function previewable(bool | Closure $condition = true): static
public function previewable(bool|Closure $condition = true): static
{
$this->isPreviewable = $condition;
@@ -97,12 +97,12 @@ class SpatieMediaLibraryFileEntry extends Entry
{
return (string) $this->evaluate($this->visibility);
}
public function isDownloadable(): bool
{
return (bool) $this->evaluate($this->isDownloadable);
}
public function isPreviewable(): bool
{
return (bool) $this->evaluate($this->isPreviewable);
@@ -124,6 +124,11 @@ class SpatieMediaLibraryFileEntry extends Entry
return $media->getUrl($conversion ?? '');
}
/**
* Get the media for the entry
*
* @return Collection<array-key, Media>
*/
public function getMedia(): Collection
{
$record = $this->getRecord();
@@ -131,13 +136,13 @@ class SpatieMediaLibraryFileEntry extends Entry
if (! $record) {
return collect([]);
}
if ($this->hasStateRelationship($record)) {
$record = $this->getStateRelationshipResults($record);
}
$records = Arr::wrap($record);
$allMedia = collect([]);
$collection = $this->getCollection() ?? 'default';
@@ -145,7 +150,7 @@ class SpatieMediaLibraryFileEntry extends Entry
foreach ($records as $record) {
/** @var Model $record */
$media = $record->getRelationValue('media');
if (! $media) {
continue;
}
@@ -160,7 +165,7 @@ class SpatieMediaLibraryFileEntry extends Entry
fn (Collection $media) => $this->filterMedia($media)
)
->sortBy('order_column');
$allMedia = $allMedia->merge($filteredMedia);
}

View File

@@ -72,7 +72,7 @@ class WorkPanelProvider extends PanelProvider
->customProfileComponents([
UserProfileFields::class,
]),
// FilamentUpload::make(),
])
->authMiddleware([

View File

@@ -18,6 +18,6 @@ parameters:
- '#BelongsToMany does not specify its types: TRelatedModel, TDeclaringModel, TPivotModel, TAccessor#'
- '#translatableTabs#'
#
# excludePaths:
# - ./*/*/FileToBeExcluded.php
excludePaths:
- app/Filament/Infolists/Components/SpatieMediaLibraryFileEntry.php