mariojgt / onix-pro

A page builder for laravel that works in a very simple and easy way, by default onix uses tailwind css, but can be easy change to your custom css.
MIT License
34 stars 6 forks source link

Quastion :How can I save page in page table #9

Closed ehsantalkhouncheh closed 3 years ago

ehsantalkhouncheh commented 3 years ago

Thank you so much for this package but i couldn't understand how can I save page in database.

mariojgt commented 3 years ago

hi there is very simple in the controler you want to save you need to get the array that have all the grapejs data ('gjs-html' , 'gjs-components' and etc) once you have that array to a json_encode() and save in a longtext field in you mysql, to load that data you do something like this in the controler first you select from your model then something like this return response()->json([ 'data' => [ 'gjs-html' => '', 'gjs-assets' => '[]', 'gjs-css' => '', 'gjs-styles' => '[]', ], ]);

if you get confuse check the browser request in the demo to understand better, i hope that this has helped you.

mariojgt commented 3 years ago

there some documentation in this link https://github.com/mariojgt/onix/wiki

ehsantalkhouncheh commented 3 years ago

Thanks for quick replay I found another issue : you used asset() Helper functions within configuration files for some reason php artisan migrate doesnt work properly now after removing asset() helper from config file php artisan will work again

mariojgt commented 3 years ago

Hi there can you explain a little more about the issue, i didn't get very if the error is with the helper or the provider.

ehsantalkhouncheh commented 3 years ago

Hi @mariojgt , Yes sure you have these 3 lines in onix config file 'onix_app_js' => asset('vendor/Onix/js/app.js'), 'onix_onix_preset_js' => asset('vendor/Onix/js/onixPreset.js'), 'grape_code_editor' => asset('vendor/Onix/js/grapeCodeEditor.js'),

when i run any artisan commands i faced with error below:

In UrlGenerator.php line 120: Illuminate\Routing\UrlGenerator::__construct(): Argument #2 ($request) must be of type Illuminate\Http\Request, null given, called in /var/ww w/html/vendor/laravel/framework/src/Illuminate/Routing/RoutingServiceProvider.php on line 65

I investigated about it and i relaized when we use url() or asset() helper inside config file artisan commands do not work anymore

https://github.com/laravel/framework/issues/7671

mariojgt commented 3 years ago

I see, thank for letting me know i will release a update for that for now i believe you can use just the path it should work.

ehsantalkhouncheh commented 3 years ago

Yes i did it already thank you so much and my last quastion is about components i cant see whole available components i mean i see just tailwind components which is good because i love tailwind but i can not see section or box which are loaded in your example, But i can not find where can i drag/drop section or box or text , etc ... Again thank you so much for amazing package , I wish you all the best

mariojgt commented 3 years ago

For that you have 2 options one is using build processes like npm if you notice once you run publish the files there is a folder inside resources/vendor/onix where i pre define some components or there is one example in the demo where you can dynamic load components from the databases for example you build the components with onix save in you database and then load that using a request available in the demo is more complicated but is dynamic.