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

[5.3] Allow models omitted by global scopes to be refreshed #15282

Merged
merged 1 commit into from
Sep 5, 2016
Merged

[5.3] Allow models omitted by global scopes to be refreshed #15282

merged 1 commit into from
Sep 5, 2016

Conversation

deefour
Copy link
Contributor

@deefour deefour commented Sep 5, 2016

RE: #15269

@taylorotwell taylorotwell merged commit 95ac0eb into laravel:5.3 Sep 5, 2016
@reinink
Copy link
Contributor

reinink commented Jan 12, 2017

This has the negative side affect of actually loading models that are soft deleted.

<?php

namespace App;

use Illuminate\Database\Eloquent\SoftDeletes;

class Thing extends Model
{
    use SoftDeletes;
}

$thing = Thing::find(1);
$thing->delete();

$thing->fresh(); // returns object
$thing = Thing::find(1); // returns null

I sort of think fresh() should replicate the behaviour of find(), which it now does not.

@deefour
Copy link
Contributor Author

deefour commented Jan 12, 2017

@reinink What you're calling a negative side effect is the single intended effect of the PR.

You're holding onto an existing model instance in $thing. The fact that it's been soft-deleted doesn't matter. You know it exists in the database. You're past the find().

fresh() is asking for the very latest attributes and requested relations for an object you already know about. The request for this info shouldn't come up empty because global scopes (soft-delete filter or otherwise) are preventing the record we already know exists from being found.

@reinink
Copy link
Contributor

reinink commented Jan 13, 2017

Okay, fair enough, but that does make this a breaking change.

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