Nel modello devi creare un metodo, ad esempio
/**
* Returns users which doesn't belong to any organization.
*
* @return mixed
*/
public static function getSomething()
{
$query = User::query()
->columns(__NAMESPACE__ . '\Pages.*')
->leftJoin(__NAMESPACE__ . '\Sections', __NAMESPACE__ . '\Pages.page_section_id = ps.section_id', 'ps')
->where('do something')
->execute();
if ($query->count()) {
return $query;
}
return false;
}