DEV Community

mostafalaravel
mostafalaravel

Posted on

1

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)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post