6 months ago

how to get accounts which are have projects

Posted 6 months ago by yafeearun


i have tried to get back the accounts which are have the projects,but accounts doesn't have the project id but invoice have account id and project id. so i mentioned the relationship like

public function invoices()
        return $this->hasManyThrough('App\Models\Invoice', 'App\Models\Project')->latest('due_date');

and i know we can get the result if we know the account id like

$account = 123
$result->with(['invoices.project'=> function($q) use ($account){

but i need to fetch only accounts which are have projects. let me help to short out it...

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