Answer the question
In order to leave comments, you need to log in
Identical configs in widgets, how to optimize?
Hello!
I have many, many widgets, they all use the same configs, or almost the same, can they be taken out somehow?
The documentation https://github.com/arrilot/laravel-widgets seems to have information, but not enough understanding of how to do it
public function __construct(array $config = [])
{
$this->addConfigDefaults([
'child_key' => 'bar'
]);
parent::__construct($config);
}
class Ac extends AbstractWidget
{
/**
* The configuration array.
*
* @var array
*/
protected $config = [
'block_id' => null,
'site_id' => null,
'type' => null,
'view' => null,
'block_title' => null,
'block_offer' => null,
'block_description' => null,
'image' => null,
'form' => null,
'form_id' => null,
'form_btn_name' => null,
'folder' => null,
'pack' => null,
'item' => null,
'size' => null,
'count' => null,
'back' => null,
'main' => null,
'section_id' => null,
'category_id' => null,
'item_id' => null,
];
/**
* Treat this method as a controller action.
* Return view() or other content to display.
*/
public function run()
{
$site_id = $this->config['site_id'];
$view = $this->config['view'];
$type = $this->config['type'];
$manager_id = $this->config['manager_id'];
$item = $this->config['item'];
$count = $this->config['count'];
$back = $this->config['back'];
$block_id = $this->config['block_id'];
$block_title = $this->config['block_title'];
....
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question