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.2.34] Laravel throws Call to undefined method Illuminate\Database\Query\Builder::getQualifiedDeletedAtColumn() #13762

Closed
ghost opened this issue May 29, 2016 · 12 comments

Comments

@ghost
Copy link

ghost commented May 29, 2016

After updating from 5.3.33 to 5.3.34 now laravel throws:

BadMethodCallException·Call to undefined method Illuminate\Database\Query\Builder::getQualifiedDeletedAtColumn()

if Model uses SoftDeletes trait. If I revert Laravel to 5.3.33 or if I disable SoftDeletes trait in my model, error disappears.

Full stacktrace:

BadMethodCallException Call to undefined method Illuminate\Database\Query\Builder::getQualifiedDeletedAtColumn() 
    vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2343 Illuminate\Database\Query\Builder::__call
    [internal] call_user_func_array
    vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:1422 Illuminate\Database\Eloquent\Builder::__call
    [internal] call_user_func_array
    vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:3506 Illuminate\Database\Eloquent\Model::__call
    vendor/laravel/framework/src/Illuminate/Database/Eloquent/SoftDeletingScope.php:23 Illuminate\Database\Eloquent\SoftDeletingScope::apply
    vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:1206 Illuminate\Database\Eloquent\Builder::applyScope
    vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:1179 Illuminate\Database\Eloquent\Builder::applyScopes
    vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:314 Illuminate\Database\Eloquent\Builder::get
    vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphTo.php:181 Illuminate\Database\Eloquent\Relations\MorphTo::getResultsByType
    vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphTo.php:142 Illuminate\Database\Eloquent\Relations\MorphTo::getEager
    vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:675 Illuminate\Database\Eloquent\Builder::loadRelation
    vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:644 Illuminate\Database\Eloquent\Builder::eagerLoadRelations
    vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:322 Illuminate\Database\Eloquent\Builder::get
    vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:494 Illuminate\Database\Eloquent\Builder::paginate
    vendor/prettus/l5-repository/src/Prettus/Repository/Eloquent/BaseRepository.php:326 Prettus\Repository\Eloquent\BaseRepository::paginate
    app/Services/Filter/AbstractFilter.php:206 Balu\Services\Filter\AbstractFilter::filter
    app/Services/Filter/Flat/FlatFilter.php:79 Balu\Services\Filter\Flat\FlatFilter::get
    app/Http/Controllers/Api/V1/Offers/offersController.php:71 Balu\Http\Controllers\Api\V1\Offers\OffersController::index
    [internal] call_user_func_array
    vendor/laravel/framework/src/Illuminate/Routing/Controller.php:80 Illuminate\Routing\Controller::callAction
    vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php:146 Illuminate\Routing\ControllerDispatcher::call
    vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php:94 Illuminate\Routing\ControllerDispatcher::Illuminate\Routing\{closure}
    [internal] call_user_func
    vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:52 Illuminate\Routing\Pipeline::Illuminate\Routing\{closure}
    app/Http/Middleware/TokenAuth/GetUserFromToken.php:53 Balu\Http\Middleware\TokenAuth\GetUserFromToken::handle
    [internal] call_user_func_array
    vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:136 Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
    [internal] call_user_func
    vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:32 Illuminate\Routing\Pipeline::Illuminate\Routing\{closure}
    [internal] call_user_func
    vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:102 Illuminate\Pipeline\Pipeline::then
    vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php:96 Illuminate\Routing\ControllerDispatcher::callWithinStack
    vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php:54 Illuminate\Routing\ControllerDispatcher::dispatch
    vendor/laravel/framework/src/Illuminate/Routing/Route.php:174 Illuminate\Routing\Route::runController
    vendor/laravel/framework/src/Illuminate/Routing/Route.php:140 Illuminate\Routing\Route::run
    vendor/laravel/framework/src/Illuminate/Routing/Router.php:724 Illuminate\Routing\Router::Illuminate\Routing\{closure}
    [internal] call_user_func
    vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:52 Illuminate\Routing\Pipeline::Illuminate\Routing\{closure}
    [internal] call_user_func
    vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:102 Illuminate\Pipeline\Pipeline::then
    vendor/laravel/framework/src/Illuminate/Routing/Router.php:726 Illuminate\Routing\Router::runRouteWithinStack
    vendor/laravel/framework/src/Illuminate/Routing/Router.php:699 Illuminate\Routing\Router::dispatchToRoute
    vendor/laravel/framework/src/Illuminate/Routing/Router.php:675 Illuminate\Routing\Router::dispatch
    vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:246 Illuminate\Foundation\Http\Kernel::Illuminate\Foundation\Http\{closure}
    [internal] call_user_func
    vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:52 Illuminate\Routing\Pipeline::Illuminate\Routing\{closure}
    vendor/itsgoingd/clockwork/Clockwork/Support/Laravel/ClockworkMiddleware.php:41 Clockwork\Support\Laravel\ClockworkMiddleware::handle
    [internal] call_user_func_array
    vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:136 Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
    [internal] call_user_func
    vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:32 Illuminate\Routing\Pipeline::Illuminate\Routing\{closure}
    vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php:37 Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::handle
    [internal] call_user_func_array
    vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:136 Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
    [internal] call_user_func
    vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:32 Illuminate\Routing\Pipeline::Illuminate\Routing\{closure}
    vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php:59 Illuminate\Cookie\Middleware\EncryptCookies::handle
    [internal] call_user_func_array
    vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:136 Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
    [internal] call_user_func
    vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:32 Illuminate\Routing\Pipeline::Illuminate\Routing\{closure}
    vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php:44 Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::handle
    [internal] call_user_func_array
    vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:136 Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
    [internal] call_user_func
    vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:32 Illuminate\Routing\Pipeline::Illuminate\Routing\{closure}
    [internal] call_user_func
    vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:102 Illuminate\Pipeline\Pipeline::then
    vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:132 Illuminate\Foundation\Http\Kernel::sendRequestThroughRouter
    vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:99 Illuminate\Foundation\Http\Kernel::handle
    public/index.php:53 [main]
@tiran133
Copy link

tiran133 commented Jun 1, 2016

i have the same issue trying to debug it at the moment

@tiran133
Copy link

tiran133 commented Jun 1, 2016

Why cloning the query from the parent model in https://github.com/laravel/framework/blob/5.2/src/Illuminate/Database/Eloquent/Relations/MorphTo.php#L180

It will clone the parent global scopes as well and if one of the morphed models don't implement this scope it will result in unexpected behaviour.

Why not replace it with a new query of the actual morphed model it works fine for me.

$query = $instance->newQuery();

You then can remove

$query->setModel($instance);

@ghost
Copy link
Author

ghost commented Jun 1, 2016

@tiran133 Could you please create PR, so that things would move faster ?

@tiran133
Copy link

tiran133 commented Jun 1, 2016

There are some other issues then... maybe someone else can help

@acasar
Copy link
Contributor

acasar commented Jun 1, 2016

@ddctd143 @tiran133 Can you try this? acasar@91e9533

It passes tests and it may fix your problems as well.

@tiran133
Copy link

tiran133 commented Jun 1, 2016

Thank you. I tried this and it works fine in my project now.

@ghost
Copy link
Author

ghost commented Jun 1, 2016

Thanks. Tried acasar commit and it works.

@sajjadrad
Copy link

I have updated to last version and still this is happening!

@sajjadrad
Copy link

I noticed that repository not updated to #13806, but I updated composer before. What's wrong?

@acasar
Copy link
Contributor

acasar commented Jun 3, 2016

It's not tagged yet - this will be in 5.2.36.

@GrahamCampbell
Copy link
Member

I understand Laravel 5.2.36 will be tagged on Monday.

@sajjadrad
Copy link

Oh, Tnx.

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

No branches or pull requests

4 participants