Skip to content

Conversation

@crynobone
Copy link
Member

This would simplify the following operation:

try {
    DB::transaction(function () use ($device) {
        $device->save();
    });
} catch (Exception $e) {
    return false;
}

to

try {
    $device->saveOrFail();
} catch (Exception $e) {
    return false;
}

Signed-off-by: crynobone [email protected]

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function will not modify the saved variable - php puts it in a different scope

@GrahamCampbell
Copy link
Collaborator

Needs tests because the current implementation doesn't actually work.

@crynobone crynobone force-pushed the feature/save-or-fail branch from 06fcda3 to 3496a5a Compare December 5, 2015 11:57
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This tests follow testNestedTransactions() with the only different with using saveOrFail().

@crynobone
Copy link
Member Author

Needs tests because the current implementation doesn't actually work.

Duplicate Illuminate\Database\Connection::transaction(), rebase and add tests.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for all this, just use finally

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, wait, ignore me - we don't want to always rollback, lol

Signed-off-by: crynobone <[email protected]>
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