Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/laraxot/module_ui_fila3 into…
Browse files Browse the repository at this point in the history
… dev
  • Loading branch information
Malebestia committed Jun 14, 2024
2 parents 83a0074 + 613d90e commit e2dec0d
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 5 deletions.
8 changes: 6 additions & 2 deletions Filament/Blocks/ImageSpatie.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Illuminate\Support\Str;
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
use Spatie\MediaLibrary\HasMedia;
use Webmozart\Assert\Assert;

class ImageSpatie
{
Expand All @@ -21,6 +22,7 @@ public static function make(
string $context = 'form',
): Block {
return Block::make($name)
->label('Immagine')
->schema([
Hidden::make('img_uuid')
->default(fn () => Str::uuid()->toString())
Expand All @@ -46,14 +48,16 @@ public static function make(
->afterStateUpdated(
function (HasForms $livewire, SpatieMediaLibraryFileUpload $component, TemporaryUploadedFile $state, Get $get, HasMedia $record) {
$livewire->validateOnly($component->getStatePath());
Assert::string($collection_name = $get('img_uuid'), '['.__LINE__.']['.__FILE__.']');
$res = $record
->addMedia($state)
->withResponsiveImages()
->toMediaCollection($get('img_uuid'));
->toMediaCollection($collection_name);
}
),

TextInput::make('caption'),
TextInput::make('caption')
->label('didascalia'),
])
->columns('form' === $context ? 2 : 1);
}
Expand Down
6 changes: 5 additions & 1 deletion Filament/Blocks/VideoSpatie.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Illuminate\Support\Str;
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
use Spatie\MediaLibrary\HasMedia;
use Webmozart\Assert\Assert;

class VideoSpatie
{
Expand All @@ -23,6 +24,7 @@ public static function make(
string $context = 'form',
): Block {
return Block::make($name)
->label('Video')
->schema([
Hidden::make('img_uuid')
->default(fn () => Str::uuid()->toString())
Expand All @@ -49,10 +51,11 @@ public static function make(
->afterStateUpdated(
function (HasForms $livewire, SpatieMediaLibraryFileUpload $component, TemporaryUploadedFile $state, Get $get, HasMedia $record) {
$livewire->validateOnly($component->getStatePath());
Assert::string($collection_name = $get('img_uuid'), '['.__LINE__.']['.__FILE__.']');
$res = $record
->addMedia($state)
->withResponsiveImages()
->toMediaCollection($get('img_uuid'));
->toMediaCollection($collection_name);
}
),
/*
Expand All @@ -64,6 +67,7 @@ function (HasForms $livewire, SpatieMediaLibraryFileUpload $component, Temporary
->columnSpanFull(),
*/
TextInput::make('caption')
->label('didascalia')
// ->columnSpanFull()
,

Expand Down
Binary file added Resources/svg/convert.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit e2dec0d

Please sign in to comment.