Eloquent tricks

By @lars · 2021-08-30 13:48

Eloquent tricks

  • By @samuel · 2021-08-31 19:29

    In Lean I have one field which has a template in the PHP class — it works well for HTML too. VSCode recognizes the language, so all of the plugins like Tailwind CSS Intellisense work there.

    protected function badgeTemplate(): Closure
    {
        return fn (self $field) => <<<HTML
            <span class="
                inline-flex justify-center items-center px-3 py-0.5 text-sm font-almost-bold rounded-full
                bg-{$field->color()}-100 text-{$field->color()}-800 dark:bg-{$field->color()}-900 dark:text-{$field->color()}-50
            ">
                {$field->displayText()}
            </span>
        HTML;
    }