@BeforeAction
Methods decorated with the @BeforeAction
decorator are called prior to any actions.
Calling one of the error status Psychic controller methods (e.g. this.forbidden()
, see status codes) from within the BeforeAction prevents later BeforeAction methods from being called and prevents the action from being called.
The exception raising Dream finders (findOrFail, findOrFailBy, firstOrFail, lastOrFail) automatically cause Psychic to return 404 not found when no model is found and prevent later BeforeAction methods from being called and prevents the action from being called.
BeforeAction can be limited to particular actions via only
:
@BeforeAction({ only: ['create', 'destroy'] })
or can be removed from particular actions via except
:
@BeforeAction({ except: ['index'] })