Changes model guarded property to use the guarded attribute
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Attributes\Guarded;
+#[Guarded(['is_admin'])]
class User extends Model
{
- protected $guarded = [
- 'is_admin',
- ];
}
Configure your rector.php:
<?php
use RectorLaravel\Rector\Class_\GuardedPropertyToGuardedAttributeRector;
use Rector\Config\RectorConfig;
return RectorConfig::configure()
->withRules([
GuardedPropertyToGuardedAttributeRector::class,
]);