DEV Community

mostafalaravel
mostafalaravel

Posted on

Laravel: Is it possible to search in a mutators?

Hello ,

I have a specific mutator called done it returns true if the 'updated_at' is larger than 'cretaed_at'.

    public function getDoneAttribute()
    {
        return ($this->created_at < $this->updated_at);
    }
Enter fullscreen mode Exit fullscreen mode

the code bellow returns an errro :

 $i = \App\User::where('done',true)->get();
Enter fullscreen mode Exit fullscreen mode

The error :

Undefined column: 7 ERROR: column "done" does not exist LINE 1:
Enter fullscreen mode Exit fullscreen mode

Top comments (0)