Eloquent tricks

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

Eloquent tricks

  • By @lars · 2021-08-31 19:02

    I should probably do it more often too, I usually stick with just using them for SQL 😬

    • 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;
      }