Guarded attribute assignment
Reports assignments to guarded attributes in Laravel Eloquent models.
Laravel Eloquent models have a $fillable and $guarded property that control mass assignment of specified attributes. This inspection detects when you try to directly assign values to guarded attributes, which may lead to security vulnerabilities.
To fix this:
Remove the attribute from the $guarded array if it should be mass assignable
Use setAttribute() method instead of direct assignment
Add the attribute to the $fillable array instead of $guarded
Locating this inspection
- By ID
Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.
LaravelEloquentGuardedAttributeAssignmentInspection- Via Settings dialog
Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.
Inspection ID: LaravelEloquentGuardedAttributeAssignmentInspection
Suppressing Inspection
You can suppress this inspection by placing the following comment marker before the code fragment where you no longer want messages from this inspection to appear:
More detailed instructions as well as other ways and options that you have can be found in the product documentation:
Inspection Details | |
|---|---|
By default bundled with: |