Skip to content

[Proposal] add non-persistent methods in EmbedsMany #151

@alexandre-butynski

Description

@alexandre-butynski

Sometimes we want to attach or detach a related model without database update like in this typical example :

public function update($id)
{
    $user = User::find($id);
    $user->fill(Input::get());
    $user->addresses()->destroy(Input::get('addresses_to_destroy'));
    $user->addresses()->createMany(Input::get('new_addresses'));
    $user->save();
}

For now, all the methods of EmbedsMany make the changes persistent. Couldn't we have methods for the same operations without database update ?

In order to not create dozens of methods with confusing names, what do you think about changing attach and detach methods to let them doing same operations that save and destroy but without persistence ? An other one could be fine for creating related object from attributes, what do you think about build ?

I'm available for quick implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions