4 months ago

Relation not working

Posted 4 months ago by Zaheer

Can someone help me why I am getting blank result. My Model relation :

    public function title()
        return $this->hasOne('App\Accounts','code','supp_code')->where('Accounts.branchid','=','Purchases.branchid');

My Controller :

           $data = Purchase::with('title')
                        WHEN purchases.posted = "1" THEN "Posted" 
                        ELSE "Unposted" 
                        END) AS status'))

I am getting null for the 'title' column. Thanks in advance.

Please sign in or create an account to participate in this conversation.