Blade

Files

  • Split Blade files into partials when possible

Partial Syntax

  • Use the x- prefix for Blade components where possible
  • Pass data to Blade components using attributes

DB Queries

  • Any data required in a Blade file should be passed from the controller
  • Do not use Eloquent queries in Blade files

PHP Usage

  • Avoid using PHP logic in Blade files

Translations

  • Use translations for all text in Blade files
  • Use the __() helper function for translations
  • Use camelCase for translation parameters

Vite

  • Use the @vite directive for js and css files
  • Use the View::asset helper function for asset paths

JavaScript

  • Add script_head and script_footer stacks for additional JavaScript
  • Where possible JavaScript should be in a JavaScript file and not in the Blade file
  • Where possible use the NPM packages for additional JavaScript packages
  • Where possible, use Alpine.js for JavaScript functionality

CSS

  • CSS required by packages should be packed using Vite
  • CSS classes should be defined in a CSS file
    • Small amounts of CSS can be put in the app.css file
    • Large amounts of CSS should be in a separate file and imported into the app.css file
Previous
Home