3 years ago

Lazy load custom function from Model

Posted 3 years ago by jsrosas

Hi All; I have a custom function in a model which does a query to another table to fetch some records.

public function disputes($user_id){
        return Dispute::where('account_name', $this->account_tu)->where('account_number', $this->account_number_tu)->orWhere('account_name', $this->account_ex)->where('account_number', $this->account_number_ex)->where('user_id', $this->user_id)->get();                

Is there a way to lazy load and append to the model collection from the controller? Right now the function is called from blade and it slows down the script. Thank you in advance.

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