Jerome V
Jerome V
FFilament
Created by Jerome V on 11/4/2024 in #❓┊help
How to add a button inside a section in form?
I want to add unset button to to photo and video Example
Forms\Components\Section::make('Photo')
->schema([
Placeholder::make('photo')
->content(fn ($record) => self::getImageContent($record) )
->visibleOn('edit')
->hidden(fn (?Advertisement $record, Forms\Get $get) =>
($record === null) || (!!$get('new_photo'))
),
Forms\Components\FileUpload::make('new_photo')
->image()
->storeFiles(false)
->moveFiles()
->imageEditor(),
Forms\Components\Button::make('unset_video')
->label('Unset Video')
->color('danger')
->action(fn () => $this->unsetVideo()),
])
->columns(2)
->collapsible()
->collapsed(),

public $unsetPhoto = false;
public $unsetVideo = false;

public function unsetPhoto()
{
$this->unsetPhoto = true;
}

public function unsetVideo()
{
$this->unsetVideo = true;
}
Forms\Components\Section::make('Photo')
->schema([
Placeholder::make('photo')
->content(fn ($record) => self::getImageContent($record) )
->visibleOn('edit')
->hidden(fn (?Advertisement $record, Forms\Get $get) =>
($record === null) || (!!$get('new_photo'))
),
Forms\Components\FileUpload::make('new_photo')
->image()
->storeFiles(false)
->moveFiles()
->imageEditor(),
Forms\Components\Button::make('unset_video')
->label('Unset Video')
->color('danger')
->action(fn () => $this->unsetVideo()),
])
->columns(2)
->collapsible()
->collapsed(),

public $unsetPhoto = false;
public $unsetVideo = false;

public function unsetPhoto()
{
$this->unsetPhoto = true;
}

public function unsetVideo()
{
$this->unsetVideo = true;
}
The case is to store temporary boolean value to update column after save in edit
7 replies
FFilament
Created by Jerome V on 10/31/2024 in #❓┊help
Cannot store select options data in another table
Good day, in some modules it's working... but in this module is not working,, I want to add gender of the user but the userDetails is separate from users table code Resource
Forms\Components\Select::make('detail.gender')
->label('Gender')
->required()
->options(Gender::array())
->placeholder('Select Gender'),
Forms\Components\Select::make('detail.gender')
->label('Gender')
->required()
->options(Gender::array())
->placeholder('Select Gender'),
user model
public function detail(): HasOne
{
return $this->hasOne(UserDetail::class, 'id');
}
public function detail(): HasOne
{
return $this->hasOne(UserDetail::class, 'id');
}
UserDetail
<?php

namespace App\Models;

use App\Cache\UserDetail\UserDetailById;
use App\Enums\UserDetail\Gender;
use App\Models\Contracts\Cacheable;
use App\Observers\UserDetailObserver;
use Illuminate\Database\Eloquent\Attributes\ObservedBy;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

#[ObservedBy([UserDetailObserver::class])]
class UserDetail extends Model implements Cacheable
{
use HasFactory;

protected $fillable = ['birthdate','gender'];

protected function casts(): array
{
return [
'birthdate' => 'date',
'gender' => Gender::class,
];
}

public function clearCache(): void
{
(new UserDetailById($this->id))->invalidate();
}
}
<?php

namespace App\Models;

use App\Cache\UserDetail\UserDetailById;
use App\Enums\UserDetail\Gender;
use App\Models\Contracts\Cacheable;
use App\Observers\UserDetailObserver;
use Illuminate\Database\Eloquent\Attributes\ObservedBy;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

#[ObservedBy([UserDetailObserver::class])]
class UserDetail extends Model implements Cacheable
{
use HasFactory;

protected $fillable = ['birthdate','gender'];

protected function casts(): array
{
return [
'birthdate' => 'date',
'gender' => Gender::class,
];
}

public function clearCache(): void
{
(new UserDetailById($this->id))->invalidate();
}
}
4 replies
FFilament
Created by Jerome V on 10/2/2024 in #❓┊help
Custom JS is not working in custom view page in RelationshipManager
So the case is this 1. We use video js using CDN What I did on my adminPanelProvider I register the CDN
public function boot(): void
{
FilamentAsset::register([
Js::make('video-js', 'https://cdn.jsdelivr.net/npm/[email protected]/dist/video.min.js'),
Js::make('videojs-contrib-eme', 'https://cdn.jsdelivr.net/npm/[email protected]/dist/videojs-contrib-eme.min.js'),
Css::make('video-css', 'https://cdn.jsdelivr.net/npm/[email protected]/dist/video-js.min.css'),
]);

}
public function boot(): void
{
FilamentAsset::register([
Js::make('video-js', 'https://cdn.jsdelivr.net/npm/[email protected]/dist/video.min.js'),
Js::make('videojs-contrib-eme', 'https://cdn.jsdelivr.net/npm/[email protected]/dist/videojs-contrib-eme.min.js'),
Css::make('video-css', 'https://cdn.jsdelivr.net/npm/[email protected]/dist/video-js.min.css'),
]);

}
and on the custom view for (EpisodesRelationManger) infolist, I want to include the custom scripts
public function infolist(Infolist $infolist): Infolist
{
return $infolist
->schema([
View::make('filament.pages.series.episodes.video')
->columnSpanFull()
->viewData(['drmData' => $this->drmData])
]);
}
public function infolist(Infolist $infolist): Infolist
{
return $infolist
->schema([
View::make('filament.pages.series.episodes.video')
->columnSpanFull()
->viewData(['drmData' => $this->drmData])
]);
}
This the custom view video.blade.php (The below scripts is not seen in devtools elements)
@if($getRecord())

<div class="h-screen flex justify-center gap-3 w-full">
<div class="h-screen aspect-video ">
<video id="video-player" class="video-js vjs-default-skin vjs-16-9" controls data-setup="{}" />
</div>
</div>
@push('scripts')
<script>
var drmData = {!! json_encode($drmData, JSON_HEX_TAG) !!};
</script>
<script type="text/javascript" src="{{ asset('js/pallycon-helper.js') }}"></script>
<script type="text/javascript" src="{{ asset('js/video-player.js') }}"></script>
@endpush
@endif
@if($getRecord())

<div class="h-screen flex justify-center gap-3 w-full">
<div class="h-screen aspect-video ">
<video id="video-player" class="video-js vjs-default-skin vjs-16-9" controls data-setup="{}" />
</div>
</div>
@push('scripts')
<script>
var drmData = {!! json_encode($drmData, JSON_HEX_TAG) !!};
</script>
<script type="text/javascript" src="{{ asset('js/pallycon-helper.js') }}"></script>
<script type="text/javascript" src="{{ asset('js/video-player.js') }}"></script>
@endpush
@endif
1 replies
FFilament
Created by Jerome V on 10/1/2024 in #❓┊help
How to register CDN in Laravel-Filament?
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/video.min.js"></script> <script src="https://cdn.tailwindcss.com"></script> <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/video-js.min.css" rel="stylesheet" /> <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/videojs-contrib-eme.min.js"></script> I tried to include it in app.blade.php but when I check it in dev tools elements it's not there
8 replies
FFilament
Created by Jerome V on 9/7/2024 in #❓┊help
Is it possible to make custom infolist entry for video?
I have this advertisement management, but in the view only the banner is displayed but in the advertisement videos is not since there is no video in infolist...
6 replies
FFilament
Created by Jerome V on 8/10/2024 in #❓┊help
How to put action on toggleColumn?
Is it possible to do like this? I want to use the toggle to block user the case is the blocked_at = timestamp blocked_by = unsignedBigInt
Tables\Columns\ToggleColumn::make('blocked_at')
->label('Block')
->sortable()
->onColor('success')
->offColor('danger')
->action(function ($record, $state) {

$blocked_at = $state ? now() : null;
$blocked_by = $state ? auth()->id() : null;

$record->update([
'blocked_at' => $blocked_at,
'blocked_by' => $blocked_by,
]);
}),
Tables\Columns\ToggleColumn::make('blocked_at')
->label('Block')
->sortable()
->onColor('success')
->offColor('danger')
->action(function ($record, $state) {

$blocked_at = $state ? now() : null;
$blocked_by = $state ? auth()->id() : null;

$record->update([
'blocked_at' => $blocked_at,
'blocked_by' => $blocked_by,
]);
}),
5 replies
FFilament
Created by Jerome V on 8/8/2024 in #❓┊help
How to handle image preview on edit if the image is from relationship
No description
1 replies
FFilament
Created by Jerome V on 8/7/2024 in #❓┊help
How to add table inside the tab content?
I have a task to create a view page on users. The scope is every tab content is different page/component so that it will not load heavily.. All the tabs are tables content example.. in my UserResource I created infolist for tab
public static function infolist(Infolist $infolist): Infolist
{
return $infolist
->schema([
Tabs::make('Tabs')
->tabs([
Tabs\Tab::make('Users')
->icon('heroicon-m-user-group')
->schema([

]),
Tabs\Tab::make('Subscriptions')
->schema([
// ...
]),
Tabs\Tab::make('Favorites')
->schema([
// ...
]),
])
]);
}
public static function infolist(Infolist $infolist): Infolist
{
return $infolist
->schema([
Tabs::make('Tabs')
->tabs([
Tabs\Tab::make('Users')
->icon('heroicon-m-user-group')
->schema([

]),
Tabs\Tab::make('Subscriptions')
->schema([
// ...
]),
Tabs\Tab::make('Favorites')
->schema([
// ...
]),
])
]);
}
How to attached/make users table in the user tab? I want to test this first and follow other tabs 1. by inserting directy the table? or 2. make a livewire component then render ?
9 replies