hasMany( 'Offer' ); } public function projectleader() { return $this->belongsTo( 'User', 'projectleader_id' ); } public function customer() { return $this->belongsTo( 'Customer' ); } public static function getAllProjects( $archive = 'F' ) { $projects = Project::with( [ 'projectleader' => function ( $q ) { $q->selectRaw( "id, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname" ); }] ) ->with( 'customer' ); if($archive == 'F') $projects = $projects->whereArchive('F'); $projects = $projects->get(); return $projects; } }