use Illuminate\Support\Arr; $array = ['p-4', 'font-bold' => $isActive, 'bg-red' => $hasError]; $isActive = false;$hasError = true; $classes = Arr::toCssClasses($array); /* * 'p-4 bg-red' */
Tip given by @dietsedev
use Illuminate\Support\Arr; $array = ['p-4', 'font-bold' => $isActive, 'bg-red' => $hasError]; $isActive = false;$hasError = true; $classes = Arr::toCssClasses($array); /* * 'p-4 bg-red' */
Tip given by @dietsedev