Loading...

This is taking longer than expected.

Coding standards

Laravel Notifications

These are the standards the analyzer applies. Every rule states what it checks and why it exists.

All standards

General Rules

  • Every notification delivered through the project's own notification channels must extend App\Notifications\Notification
  • Never extend Illuminate\Notifications\Notification directly in those notifications
  • Those notifications must define: subject() and description()
  • image() is optional. The base class already resolves a sensible default, so only override it when the notification needs a different image.
  • Use php artisan make:notification MyNotification (the stub already extends the base class) to create a new Notification
  • Do not force channels manually unless justified
  • This rule applies only to actual Laravel notification classes, normally files under app/Notifications or classes extending Laravel/project notification base classes.
  • Inside namespace App\Notifications;, extends Notification is valid because it resolves to the local App\Notifications\Notification base class. Do not require writing extends App\Notifications\Notification or importing the class in that namespace. The same applies to sub-namespaces such as App\Notifications\Auth when they import the base class.
  • These rules cover notifications addressed to registered users through the project's inbox, mail, and web push channels. Notifications sent to someone who is not a registered user yet — such as the code that verifies a phone or email during sign-up, where the User model is still unsaved — are outside them.
  • The detectable signal is the delivery channel. The base class builds the mail, database, and web push payloads out of subject(), description(), and image(). A notification that delivers only through a dedicated channel the base class does not implement — for example a verification code sent through a custom SmsChannel with its own toSms() — gains nothing from the base class and is outside this rule. Do not require it to extend the base class or to define subject() and description().
Weblabor Logo Developed by Weblabor