Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 2 years ago.
0

Hi, I have just solved this problem. This is because I overwrite the constructor of model but did not invoke parent's constructor. After I add parent::__construct(); everything is OK. I think this should add to the document because this statement doesn't matter in earlier versions.

Last updated 2 years ago.
0

I have same issue,

On laravel 4.2, User::all() line gets all model adding soft deleted models..

Before laravel 4.2 Same code - User::all() - only gets model is not soft deleted...

In this case, I have to use my basic method:

    /**
     * To remove model that has been removed
     * 
     * @param object $models    models
     * @return object           only model wasn't removed 
     */    
    public function RemoveSoftDeleted($models) {
        
        foreach ($models as $k => $v) {
            
            if ($v->deleted_at !== null) {
                
                unset($models[$k]);
            }
        }
        
        return $models;
    }

Last updated 2 years ago.
0

Thank you for the tip on parent::__construct() ... I had the same problem, and it was so annoying!

Niels.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

devbean devbean Joined 29 Jun 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.