z3d0x / filament-fabricator Goto Github PK
View Code? Open in Web Editor NEWBlock-Based Page Builder Skeleton for your Filament Apps
Home Page: https://filamentphp.com/plugins/fabricator
License: MIT License
Block-Based Page Builder Skeleton for your Filament Apps
Home Page: https://filamentphp.com/plugins/fabricator
License: MIT License
When using Octane (tried both Swoole and RoadRunner for confirmation), pages occasionally load correctly on the first request, but it seems that subsequent requests fail with an error about the layout missing. The same site works correctly without Octane.
Good day,
There is an issue with this package especially if you are dealing with data outside of the normal Fabricator process.
Let me explain:
I am building blocks as usual but some of the blocks just need data from a model. The documentation states you can do something like this:
return ['foo' => 'bar']
Sometimes it works, and sometimes it does not and returns the above error. I wish this could work.
This is a great package idea.
The block:
schema([ Placeholder::make('') ->content('Please manage under support management') ]); } public static function mutateData(array $data): array { $data = [ 'donors' => Donor::all() ]; return $data; } } The error: ErrorException PHP 8.1.10 9.52.6 Undefined array key "data" ![image](https://user-images.githubusercontent.com/80934965/233768457-0e8c8c9a-8e47-42da-90ac-7ab86b7762e1.png)A common practice in laravel applications is to have Model::shouldBeStrict() checks active in non-prod environments:
https://laravel.com/docs/10.x/eloquent#configuring-eloquent-strictness.
Currently, when strict mode is activated, a LazyLoadingViolationException is thrown in:
Z3d0X\FilamentFabricator\FilamentFabricatorManager::setPageUrl()
in the line if (filled($page->children))
when attempting to save a SubPage (a page with parent) from the filament admin panel.
Model::shouldBeStrict();
to the boot() function of the AppServiceProvider.php public function boot()
{
Model::shouldBeStrict(); // should normally only be active in non-prod environments
}
The error does not happen if the line if (filled($page->children))
is replaced with if ($page->children()->count() > 0 && filled($page->children))
, which seems to suggest that the Violation is not - strictly speaking - a lazy loading violation, but a missing attribute call violation.
hi
my stacktrace: https://flareapp.io/share/v5pba3lP
I use
filament v3.2.44
livewire/liveire v3.4.7
spatie/laravel-translatable v.6.6.2
z3d0x/filament-fabricator v2.1.1
filament/spatie-laravel-translatable-plugin v3.2.44
I was so happy when I connected everything and the translation worked. But after a while I found the problem.
Unfortunately, removing blocks from the page does not work
When I delete block and push save, I get error
Undefined array key "type"
Page
Modeltables
ref: https://github.com/spatie/laravel-activitylog/blob/main/config/activitylog.php#L38-L51
This getName()
method is called during block registration
filament-fabricator/src/PageBlocks/PageBlock.php
Lines 22 to 25 in 50f0cc6
A potential viable solution might be to Explicitly set a name like in Layouts
filament-fabricator/src/Layouts/Layout.php
Lines 11 to 16 in 50f0cc6
make:page-block
could auto to generate $name
.
This would be a breaking a change, since existing application would need to explicitly set the $name
.
Other ideas are welcome
I use Fabricator with Spatie Translatable.
So slugs are stored like:
{"nl":"test-nl","de":"test-de"}
When the Dutch locale is set, the pageUrls are like this:
$pageUrls[1] = "/test-nl"
This is Cached with the key:
filament-fabricator::page-urls
When the German page is requested, the Dutch $pageUrls are returned so no page is found.
Original PR #133
Problem:
The application threw an exception for a duplicate entry for the key pages.pages_slug_unique when attempting to insert a new page with the same slug as an existing page, but with a different parent.Solution:
The unique index on the slug column has been removed, and a new compound unique index has been introduced on the combination of slug and parent_id columns. This allows the same slug to be used as long as it has a different parent, thus ensuring unique URLs for different page hierarchies while avoiding the integrity constraint violation.
Original PR was closed because it updated the existing migration file, this way would for new installations of this package. To solve this issue for existing applications using this package a new migration must be created, for the proposed solution
Note: this feature is implemented just need to be documented
If you add custom columns to Page Model you can use schema slots to add additional fields to the Page Resource Form, without overriding it.
Example:
use Z3d0X\FilamentFabricator\Facades\FilamentFabricator;
// in boot of a service provider
FilamentFabricator::registerSchemaSlot('sidebar.after', [
TextInput::make('seo_title'),
Textarea::make('seo_description'),
]);
Available Schema Slots:
blocks.before
blocks.after
sidebar.before
sidebar.before
Hi!
I'm encountering a strange issue, as the "php artisan queue:work" command always fails when adding a job to the default queue:
Exception: Filament Fabricator: Layout 'default' not found in file C:\xampp\htdocs\filament-test-export\vendor\z3d0x\filament-fabricator\src\Http\Controllers\PageController.php on line 31
The job is using spatie/laravel-export which crawls the urls of the website.
When using the commands "php artisan queue:work --once" and "php artisan queue:listen", everything is fine, but running "php artisan queue:work" will throw the exception above, although the layout has been created by running "php artisan filament-fabricator:layout DefaultLayout".
Do you have any clue of what can cause this error?
Thx!
Hi,
When you try to use this package with a layout extend by Laravel JetStram default layout. You got a Javascript error :
Uncaught (in promise) Component not found: JJ8Yux7OzeM3ZVAnkGOG
Steps to reproduce :
I've tried with theses steps and got this error. Is seems we can not use the preview with a template which contains livewire components.
EDIT : When I remove @livewire('navigation-menu') it works perfectly. I've tried to use Filament Hook like this :
{{ \Filament\Support\Facades\FilamentView::renderHook('filament-fabricator::menu') }}
FilamentView::registerRenderHook(
'filament-fabricator::menu',
fn (): string => Blade::render('@livewire(\'navigation-menu\')'),
);
But got the same error
Any solution to fix this ?
Thanks,
Default routing config is
'routing' => [
'enabled' => true,
'prefix' => null, // /pages
],
With default values, you will receive 404 errors for non-filament routes with ModelNotFoundException for No query results for model [Z3d0X\FilamentFabricator\Models\Page].
1st workaround is to disable the routing but then you won't be able to use fabricator page routes.
2nd workaround is to use a prefix for the fabricator routing eg: pages
.
However non-null prefix values cause another minor bug for the Visit
action of Page resource.
Filament default route prefix is /admin
and fabricator will send you to /admin/pages/xyz
instead of /pagess/page-xyz
when you click the Visit
action of your fabricator page.
I was wondering how to pass data to a specific page layout.
Lets say i have a ProductResource and a layout Products.
I want to be able to collect all products and pass it to the product layout.
Like this:
return view('products', ['products' => $products]);
I don't know if this is already possible.
When I try to use it inside Docker and run Artisan commands, it always throws this exception:
`SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "pages" does not exist
LINE 1: select * from "pages"
^ (Connection: pgsql, SQL: select * from "pages")
at vendor/laravel/framework/src/Illuminate/Database/Connection.php:822
818▕ $this->getName(), $query, $this->prepareBindings($bindings), $e
819▕ );
820▕ }
821▕
➜ 822▕ throw new QueryException(
823▕ $this->getName(), $query, $this->prepareBindings($bindings), $e
824▕ );
825▕ }
826▕ }
1 [internal]:0
Illuminate\Foundation\Application::Illuminate\Foundation{closure}(Object(Z3d0X\FilamentFabricator\FilamentFabricatorServiceProvider))
+12 vendor frames`
this error happened because of the codes inside bootingPackage()
Hey, great plugin!
Is it possible to use the Fabricator with multiple models? would like to use it with pages and posts.. but didnt see anything in the documentation.
thanks
opt-in feature for draft/publish states
getLabel()
is deprecated Use getModelLabel()
instead.
https://github.com/Z3d0X/filament-fabricator/blob/2.x/src/Resources/PageResource.php#L182
getPluralLabel()
is deprecated Use getPluralModelLabel()
instead.
https://github.com/Z3d0X/filament-fabricator/blob/2.x/src/Resources/PageResource.php#L187
Expected Update:
public static function getModelLabel(): string
{
return __('filament-fabricator::page-resource.labels.page');
}
public static function getPluralModelLabel(): string
{
return __('filament-fabricator::page-resource.labels.pages');
}
Tried installing the package but I am getting a sub-dependency error about pboivin/filament-peek ^2.0
I am on Laravel ^10.10, Filament ^3.0-stable
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Root composer.json requires z3d0x/filament-fabricator ^2.0 -> satisfiable by z3d0x/filament-fabricator[v2.0.0, v2.0.1].
- z3d0x/filament-fabricator[v2.0.0, ..., v2.0.1] require pboivin/filament-peek ^2.0 -> found pboivin/filament-peek[v2.0.0-alpha1, ..., 2.x-dev] but it does not match your minimum-stability.
How to add multiple page models
I've worked out you can add blocks to any Model.
public static function form(Form $form): Form
{
return $form
->schema([
TextInput:make('title'),
Group::make()
->schema([
PageBuilder::make('blocks')
->label(__('filament-fabricator::page-resource.labels.blocks'))
->blocks(FilamentFabricator::getPageBlocks()),
])->columnSpan(2),
]);
}
And add a json field called `blocks to your table.
$table->json('blocks')->nullable();
Seems to work fine, so..? 🤷♂️
Originally posted by @tobz-nz in #44 (comment)
Allows custom fields to be added to PageResource
.
Fields can be placed:
Hi,
It seems that creating a page without a slug is not possible? i would like to create a home page..
also how would you do a blog with single post page?
thanks for answers
First of all, great plugin! Thanks for your work!
I noticed that queries in PageBlocks
are fired every time you visit a page. Take for example this block:
public static function getBlockSchema(): Block
{
return Block::make('my-block')
->schema([
Select::make('users')
->options(User::pluck('name', 'id'))
]);
}
public static function mutateData(array $data): array
{
return array_merge($data, [
'users' => Cache::remember('my_block_users', 60, function () use ($data) {
return User::find($data['users']);
}),
]);
}
When visiting the page, the mutated data is cached but the query for theSelect
(User::pluck('name', 'id')
) field is still running every time.
Cheers, Martin
Home page not working.
Thank you
Hello @Z3d0X
First, I want to thank you again for such a beautiful implementation of blocks in Filament!
So now, I ran into a problem: I deleted a block after a given page was saved into the database.
I expected that the rendering mechanism ignored the JSON's non-existing blocks, but an exception was thrown.
Is this the desired behavior?
Below is a screenshot and the video link at the timestamp where it happened. It's in Portuguese, but without sound, you realize what happened. After undeleting the block files, it went back to normal
I changed fabricator table name so it couldn't conflict with "pages" table I want to create later. Got an error during migration.
The config config/filament-fabricator.php
:
<?php
// config for Z3d0X/FilamentFabricator
return [
...
'table_name' => 'fabricator_pages',
];
The error on php artisan migrate
:
SQLSTATE[HY000]: General error: 1824 Failed to open the referenced table 'pages' (Connection: mysql, SQL: alter table `fabricator_pages` add constraint `fabricator_pages_parent_id_foreign` foreign key (`parent_id`) references `pages` (`id`) on delete cascade on update cascade)
Hey guys,
firs tof all: great work!
I have issues with image fields. The upload works as expected, but inside of the template the field remains null
.
Is this a known issue or am I doing something wrong or have something not yet configured ?
Potential Idea:
PageBuilder
(extend Filaments' Builder
FieldGoodday,
As mentioned on Twitter, Fabricator overrides application routes. The only route which works is the "/admin" route to access filament if installed in an existing project. One can always change this behaviour in the config file, not too sure what the implications thereof will be as I have not fully tested it. You mentioned that application routes should take priority over fabricator routes. Kindly look into this. Thanks a mill.
Hi,
i have noticed that the Sessions seems to be Empty or not Set when a User visits a Page from the Fabricator.
I have tested this with a fresh and clean Installation of Laravel, Filament and this Package.
@dump(auth())
in the Layout-File returns "null", even when a User is logged in
I am wondering if anyone else can confirm this
Thanks!
Hello,
I've been playing around with this awesome package and it does a wonderful job.
I are trying to use this to act like a "Page builder" for simple frontend website.
I want to create column options for the page block, and tried this simple approach, basically to provide PageBuilder itself in the schema. However it goes to infinite loop and throws this error.
Xdebug has detected a possible infinite loop, and aborted your script with a stack depth of '512' frames
Anyway to get this issue resolved ? Or maybe another approach to manage the column option.
Here's the code
public static function getBlockSchema(): Block
{
return Block::make('two-column')
->columns(2)
->schema([
PageBuilder::make('block1')->label(__('filament-fabricator::page-resource.labels.blocks')),
PageBuilder::make('block2')->label(__('filament-fabricator::page-resource.labels.blocks')),
]);
}
Sorry Discussions are disabled so asking this question here instead.
I can't figure out how to add fabricator to my other models - is it fixed to only the provided Pages model?
I really want to use it on a number of different models - is this possible?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.