Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[10.x] Can apply WithoutRelations to entire class #48068

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
20 checks passed
@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.

None yet

3 participants