HansSchouten / Laravel-Pagebuilder

A drag and drop pagebuilder to manage pages in any Laravel project
https://www.phpagebuilder.com
MIT License
783 stars 182 forks source link

Page blank with use_router set to true or false #21

Closed emperorjm closed 4 years ago

emperorjm commented 4 years ago

I am integrating this package into a Laravel application that has a lot of routes and the reason the "use_router" value was set to false;

'router' => [
        'class' => PHPageBuilder\Modules\Router\DatabasePageRouter::class,
        'use_router' => false
    ],

I then added the route to my web.php file:

Route::get('/test1', 'TestController@index');

The following is the actual function call:

/**
     * 
     *
     * @return \Illuminate\Http\Response
     */
    public function index(Request $request)
    {
        $builder = new LaravelPageBuilder(config('pagebuilder'));
        $builder->handlePublicRequest();
    }

On going to the 'test1' route I am just getting a blank page. I have Debugbar installed and APP_DEBUG set to true but the Debugbar is not shown and there no errors displayed.

HansSchouten commented 4 years ago

Do you have a page stored in your database with route /test1? The handlePublicRequest() method looks at the current URI and shows the page that matches with that.

emperorjm commented 4 years ago

Yes there is a page within the "pagebuilder__pages" table with the respective record in the translation table with the route route set:

# id, page_id, locale, title, route, created_at, updated_at
'1', '1', 'en', 'Test page', 'test1', NULL, NULL
emperorjm commented 4 years ago

I just decided to change the route from "test1" to "/test1" in the translation table and it works. It seem to be required due to me adding the "/" within the route:

Route::get('/test1', 'TestController@index');

HansSchouten commented 4 years ago

Yes that is correct. The URL should start with a /, but I will remove this restriction later on.