Skip to content

Get Relationship data before update #8615

Closed Answered by leandrocfe
Professor93M asked this question in Help
Discussion options

You must be logged in to vote

I think you can use saveRelationshipsUsing() in your relationship

->saveRelationshipsUsing(static function ($component, Model $record, $state) {
    
    //$record->yourRelationship  original data
    //$state current data
    
    $newState = [1, 2, 3];

    $relationship = $component->getRelationship();
    $relationship->sync($newState); //associate, attach, etc..
})

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@leandrocfe
Comment options

Answer selected by Professor93M
@jwhoami
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
4 participants