plugin icon indicating copy to clipboard operation
plugin copied to clipboard

[Feature Request]: Dynamic View Click Through

Open browner12 opened this issue 1 year ago • 1 comments

Feature Description

Sometimes I'll have a component that supports different "skins", which just means that we conditionally load a view. By passing a variable to the view($pathToFile) method we lose the ability to click through to the view.

It would be amazing if the plugin could analyze the variable, and provide a drop down of any static options (like it does for other features) to allow us to select. I realize it would be impossible to handle any non-static values, and those could be ignored.

$viewPath = match ($skin) {
    'baja-blast' => 'customs.baja-blast',
    'code-red'   => 'customs.code-red',
    'non-static' => 'customs.wont-work-' . rand(1, 10),  //this one would not work
    default      => 'default.path',
};


return view($viewPath);

browner12 avatar Oct 09 '24 21:10 browner12

I can try to make this working.

return view(match ($skin) {
    'baja-blast' => 'customs.baja-blast',
    'code-red'   => 'customs.code-red',
    'non-static' => 'customs.wont-work-' . rand(1, 10),  //this one would not work
    default      => 'default.path',
});

adelf avatar Oct 18 '24 16:10 adelf

awesome, thanks!

browner12 avatar Dec 18 '24 16:12 browner12