Find the best Rector rule to solve your problem. Searching through 895 rules.
Found 31 rules:
Changes the delay property to use the Delay attribute
use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Queue\Attributes\Delay;
+#[Delay(10)]
final class ProcessPodcast implements ShouldQueue
{
- public $delay = 10;
}
Changes model visible property to use the Visible attribute
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Attributes\Visible;
+#[Visible(['name', 'email'])]
class User extends Model
{
- protected $visible = [
- 'name',
- 'email',
- ];
}
Changes model timestamps = false property to use the WithoutTimestamps attribute
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Attributes\WithoutTimestamps;
+#[WithoutTimestamps]
class EventLog extends Model
{
- public $timestamps = false;
}
Changes model table-related properties to use the Table attribute
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Attributes\Table;
+#[Table(name: 'users', key: 'user_id', keyType: 'string', incrementing: false)]
class User extends Model
{
- protected $table = 'users';
-
- protected $primaryKey = 'user_id';
-
- protected $keyType = 'string';
-
- protected $incrementing = false;
}
Changes model newCollection method to use the CollectedBy attribute
use Illuminate\Database\Eloquent\Model;
-use Illuminate\Database\Eloquent\Collection;
use App\Collections\UserCollection;
+use Illuminate\Database\Eloquent\Attributes\CollectedBy;
+#[CollectedBy(UserCollection::class)]
class User extends Model
{
- /**
- * @param array<int, \Illuminate\Database\Eloquent\Model> $models
- * @return \Illuminate\Database\Eloquent\Collection<int, \Illuminate\Database\Eloquent\Model>
- */
- public function newCollection(array $models = []): Collection
- {
- return new UserCollection($models);
- }
}
Changes model fillable property to use the fillable attribute
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Attributes\Fillable;
+#[Fillable(['name', 'email'])]
class User extends Model
{
- protected $fillable = [
- 'name',
- 'email',
- ];
}
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',
- ];
}
Changes the hidden property to use the Hidden attribute on console commands
use Illuminate\Console\Command;
+use Illuminate\Console\Attributes\Hidden;
+#[Hidden]
class SendEmails extends Command
{
- protected $hidden = true;
}
Changes the help property to use the Help attribute
use Illuminate\Console\Command;
+use Illuminate\Console\Attributes\Help;
+#[Help('This command sends emails to all users')]
class SendEmails extends Command
{
- protected $help = 'This command sends emails to all users';
}
Changes model incrementing = false property to use the WithoutIncrementing attribute
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Attributes\WithoutIncrementing;
+#[WithoutIncrementing]
class User extends Model
{
- public $incrementing = false;
}
Changes model appends property to use the appends attribute
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Attributes\Appends;
+#[Appends(['full_name'])]
class User extends Model
{
- protected $appends = [
- 'full_name',
- ];
}
Changes the backoff property to use the Backoff attribute
use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Queue\Attributes\Backoff;
+#[Backoff(3)]
final class ProcessPodcast implements ShouldQueue
{
- public $backoff = 3;
}
Changes the maxExceptions property to use the MaxExceptions attribute
use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Queue\Attributes\MaxExceptions;
+#[MaxExceptions(3)]
final class ProcessPodcast implements ShouldQueue
{
- public $maxExceptions = 3;
}
Changes the signature property to use the Signature attribute
use Illuminate\Console\Command;
+use Illuminate\Console\Attributes\Signature;
+#[Signature('mail:send {user}')]
class SendEmails extends Command
{
- protected $signature = 'mail:send {user}';
}
Changes the timeout property to use the Timeout attribute
use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Queue\Attributes\Timeout;
+#[Timeout(120)]
final class ProcessPodcast implements ShouldQueue
{
- public $timeout = 120;
}
Changes the connection property to use the Connection attribute on queue jobs
use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Queue\Attributes\Connection;
+#[Connection('redis')]
final class ProcessPodcast implements ShouldQueue
{
- public $connection = 'redis';
}
Changes the collects property to use the Collects attribute
use App\Http\Resources\UserResource;
+use Illuminate\Http\Resources\Attributes\Collects;
use Illuminate\Http\Resources\Json\JsonResource;
+#[Collects(UserResource::class)]
class UserCollection extends JsonResource
{
- protected $collects = UserResource::class;
}
Changes the queue property to use the Queue attribute
use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Queue\Attributes\Queue;
+#[Queue('podcasts')]
final class ProcessPodcast implements ShouldQueue
{
- public $queue = 'podcasts';
}
Changes the failOnTimeout property to use the FailOnTimeout attribute
use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Queue\Attributes\FailOnTimeout;
+#[FailOnTimeout(true)]
final class ProcessPodcast implements ShouldQueue
{
- public $failOnTimeout = true;
}
Changes the deleteWhenMissingModels property to use the DeleteWhenMissingModels attribute
use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Queue\Attributes\DeleteWhenMissingModels;
+#[DeleteWhenMissingModels]
final class ProcessPodcast implements ShouldQueue
{
- public $deleteWhenMissingModels = true;
}
Changes the uniqueFor property to use the UniqueFor attribute
use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Queue\Attributes\UniqueFor;
+#[UniqueFor(1800)]
final class ProcessPodcast implements ShouldQueue
{
- public $uniqueFor = 1800;
}
Changes model connection property to use the Connection attribute
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Attributes\Connection;
+#[Connection('sqlite')]
class User extends Model
{
- protected $connection = 'sqlite';
}
Changes model touches property to use the touches attribute
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Attributes\Touches;
+#[Touches(['posts'])]
class User extends Model
{
- protected $touches = [
- 'posts',
- ];
}
Changes the aliases property to use the Aliases attribute
use Illuminate\Console\Command;
+use Illuminate\Console\Attributes\Aliases;
+#[Aliases(['email:send'])]
class SendEmails extends Command
{
- protected $aliases = ['email:send'];
}
Changes the stopOnFirstFailure property to use the StopOnFirstFailure attribute
use Illuminate\Foundation\Http\FormRequest;
+use Illuminate\Foundation\Http\Attributes\StopOnFirstFailure;
+#[StopOnFirstFailure]
class StorePostRequest extends FormRequest
{
- protected $stopOnFirstFailure = true;
}
Changes the preserveKeys property to use the PreserveKeys attribute
+use Illuminate\Http\Resources\Attributes\PreserveKeys;
use Illuminate\Http\Resources\Json\JsonResource;
+#[PreserveKeys]
class UserResource extends JsonResource
{
- protected $preserveKeys = true;
}
Changes model hidden property to use the hidden attribute
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Attributes\Hidden;
+#[Hidden(['password'])]
class User extends Model
{
- protected $hidden = [
- 'password',
- ];
}
Changes the tries property to use the Tries attribute
use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Queue\Attributes\Tries;
+#[Tries(3)]
final class ProcessPodcast implements ShouldQueue
{
- public $tries = 3;
}
Changes model dateFormat property to use the DateFormat attribute
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Attributes\DateFormat;
+#[DateFormat('U')]
class User extends Model
{
- protected $dateFormat = 'U';
}
Changes the description property to use the Description attribute
use Illuminate\Console\Command;
+use Illuminate\Console\Attributes\Description;
+#[Description('Send marketing emails to users')]
class SendEmails extends Command
{
- protected $description = 'Send marketing emails to users';
}
Changes the errorBag property to use the ErrorBag attribute
use Illuminate\Foundation\Http\FormRequest;
+use Illuminate\Foundation\Http\Attributes\ErrorBag;
+#[ErrorBag('custom')]
class StorePostRequest extends FormRequest
{
- protected $errorBag = 'custom';
}