Erwin.van.den.Berg
Erwin.van.den.Berg
FFilament
Created by Erwin.van.den.Berg on 9/17/2024 in #❓┊help
Form Builder Component
Is it possible in Filament to store a Builder block as a related record just as with a Repeater Item?
1 replies
FFilament
Created by Erwin.van.den.Berg on 11/24/2023 in #❓┊help
Problems adding plugin (Filament navigation)
When adding the Filament Navigation plugin and configuring it to use a new item Type. I receive an error message stating 'call to a member function connection() on null' my code is: ->plugin(FilamentNavigation::make()->itemType('Page', [ Select::make('post_id') ->options(Page::all()->pluck('title', 'id')->toArray()) ])); Anyone who knows what I do wrong?
1 replies
FFilament
Created by Erwin.van.den.Berg on 10/14/2023 in #❓┊help
Pre processing listed records of a resource
I have create a resource which is based on a Page model. I want to show the pages in their parent child hierarchy. I have found next solution to do so in regular Laravel. But can not find the correct way to do this so I can use it in a Filament list of resources. Optionally I want to allow the filament sorting options within the hierarchy sorting:
$pages = Page::all();

$generator = function (Collection $level, $prefix = '') use ($pages, &$generator) {
// here we are sorting by 'id', but you can sort by another field
foreach ($level->sortBy('id') as $item) {
// yield a single item
yield $item;


//$item->level = $level->count();

if($prefix != '')
{
$item->title = $prefix . ' ' . $item->title;
}

// continue yielding results from the recursive call
yield from $generator($pages->where('parent_id', $item->id ), $prefix . '— ');
}
};

$results = LazyCollection::make(function () use ($pages, $generator) {
// yield from root level
$prefix = '';

yield from $generator($pages->where('parent_id', null), $prefix);
})->flatten()->collect();

return $results->toJson();
$pages = Page::all();

$generator = function (Collection $level, $prefix = '') use ($pages, &$generator) {
// here we are sorting by 'id', but you can sort by another field
foreach ($level->sortBy('id') as $item) {
// yield a single item
yield $item;


//$item->level = $level->count();

if($prefix != '')
{
$item->title = $prefix . ' ' . $item->title;
}

// continue yielding results from the recursive call
yield from $generator($pages->where('parent_id', $item->id ), $prefix . '— ');
}
};

$results = LazyCollection::make(function () use ($pages, $generator) {
// yield from root level
$prefix = '';

yield from $generator($pages->where('parent_id', null), $prefix);
})->flatten()->collect();

return $results->toJson();
2 replies
FFilament
Created by Erwin.van.den.Berg on 6/26/2023 in #❓┊help
Error message isVisible()
8 replies
FFilament
Created by Erwin.van.den.Berg on 5/4/2023 in #❓┊help
Builder blocks with spatie media library field
I am using the builder component with a spatie media library field in it. The builder field is stored in a json column. When however using two or more of these blocks, they all get the same image. This is quite logic as the images are related to a model and collection. Is there a way to make this work? I already figured out that I could make it work using a related model for each block but I am wondering if there is also a solution when storing in the json column?
16 replies