#update new class structure for Job class

3 messages · Page 1 of 1 (latest)

near lintel
#

hi, i have an application that originally started on Laravel 8 and has been continuously upgraded over time. it is now running on laravel 12 and works perfectly fine.

my question is about my job classes. they are still using the old boilerplate, as shown in the code below. since the application is already on Laravel 12, is it safe to remove the old traits from my Job classes that were commonly used in earlier versions?

<?php

namespace App\Jobs;

use App\Models\Podcast;
use App\Services\AudioProcessor;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable; // safe to remove?
use Illuminate\Queue\InteractsWithQueue; // safe to remove?
use Illuminate\Queue\SerializesModels; // safe to remove?

class ProcessPodcast implements ShouldQueue
{
    use Queueable;
    use Dispatchable, InteractsWithQueue, SerializesModels; // safe to remove?

    /**
     * create a new job instance.
     */
    public function __construct(
        public Podcast $podcast,
    ) {}

    // ....
}

thanks in advance 🍕

rose owl
near lintel
#

update,

it broke when you call ProcessPodcast::dispatch(...), so you have to change to dispatch(new ProcessPodcast(...))