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( [ 'offers' => function ( $q ) { $q->whereArchive( 'F' ) ->with( [ 'payment' => function ( $q ) { $q->selectRaw( '*' ); }] ); }] ) ->with( 'customer' ); if ( $archive == 'F' ) $projects = $projects->whereArchive( 'F' ); $projects = $projects->get(); return $projects; } public static function removeProject( $projectID ) { Project::whereId($projectID)->delete(); } }