Skip to content

Conversation

@cosmastech
Copy link
Contributor

@cosmastech cosmastech commented Aug 14, 2023

Can target the entire class so that no model has relationships set. Will not interfere with other properties.

use App\Models\Podcast;
use App\Models\User;
use App\Models\DistributionPlatform;
use App\DataObject;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\Attributes\WithoutRelations;

#[WithoutRelations]
class ProcessPodcastJob
{
    use SerializesModels;
 
    public function __construct(
        public Podcast $podcast,
        public User $user,
        public DistributionPlatform $platform,
        public DataObject $dataObject
    ) {}
}

All of the models will be serialized without relationships (rather than having to repeatedly apply the attribute to each model), while non-models will be unaffected.

@cosmastech cosmastech force-pushed the feature/without-relationships-target-class branch from ef4042f to 9063f03 Compare August 14, 2023 21:00
@taylorotwell taylorotwell merged commit c1e6281 into laravel:10.x Aug 14, 2023
@cosmastech cosmastech deleted the feature/without-relationships-target-class branch August 14, 2023 23:37
@siarheipashkevich
Copy link
Contributor

@cosmastech thanks for your job, what do you think about adding documentation for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants