HansSchouten / Laravel-Pagebuilder

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

Dynamic option in config.php for block setting #27

Closed kousar2334 closed 4 years ago

kousar2334 commented 4 years ago

I have written this code into config.php for block setting

`<?php
use App\Http\Controllers\backend\PageController;
$ctrl=new PageController();
$categories=$ctrl->getCategories();
return [
    'title' => 'Banner',
    'category' => 'Banner',
    'icon' => 'fa fa-server',
    "settings" => [
      "first-section" => [
            "type" => "select",
            "label" => "Select First Block Category",
            "options" =>$categories,
        ],  `

Code in controller

public function getCategories()
   {
    $cats=DB::table('news_categories')->select('name')->get();
    return $cats;
   }
The output is 

Screenshot_2020-06-29_23-11-35 Screenshot_2020-06-29_23-11-59

Why the option's value is undefined. Please help ..

HansSchouten commented 4 years ago

This is the code that sets your custom selector options: https://github.com/HansSchouten/PHPageBuilder/blob/master/src/Modules/GrapesJS/Block/BlockAdapter.php#L136. If you look a few lines further, it shows the expected format. I guess you don't have an id key in the array.

RishiWebVeerIT commented 1 year ago

How can I add Js and CSS in the master file via config or view.php file