Models

Location

App/Models

Properties

  • $guarded - only guard ['id']
  • $hidden - generally includes the dates 'created_at', 'updated_at', 'deleted_at', 'password', ... and other things we should't show the user
  • $dates - any date or timestamp should be added to this array
  • $casts - all tinyints (booleans) should be casts as boolean here

Sections of Code

*Note use the *** separator to separate each section*

  • Modifications (when applicable), an example is in our User Model where we call the boot function to add a token
  • Scopes
  • Relations - Relations should be listed in alphabetical order.
  • CRUD - Really this is creating and updating
  • General Functions
  • Helpers - Something like isAdmin()