File: D:/HostingSpaces/SBogers10/werkenbij.komma.pro/app/Komma/Composers/ContentSliderComposer.php
<?php
namespace App\Komma\Composers;
use Illuminate\View\View;
class ContentSliderComposer
{
/**
* @param View $view
*/
public function compose(View $view)
{
$viewData = $view->getData();
$buttonData = [];
$tabs = $viewData['component']->tabs;
foreach($tabs as $tab) {
//Check if button exists
if(
$tab->buttons &&
count($tab->buttons) > 0 &&
$tab->buttons[0]->translation
) {
$button = $tab->buttons[0];
//Check if button has label and url. If so, add to buttonData.
if($button->translation->label && $button->translation->url) {
$hash = spl_object_hash($tab);
$buttonData[$hash] = [
'buttonText' => $button->translation->label ?: null,
'buttonLink' => $button->translation->url ?: null,
];
}
}
}
$view->with('buttonData', $buttonData);
}
}