belongsTo( 'Project' ); } public function external() { return $this->belongsTo( 'External' ); } public static function saveProjectcost( $projectID, $project ) { $project = (array) $project; if ( $projectID == 0 ) { $project = Self::create( $project ); $projectID = $project['id']; } else { Self::whereId( $projectID )->update( $project ); } return $projectID; } public static function getCostsPerPerProject( $projectID ) { $projectCosts = Projectcost::selectraw( 'ROUND(COALESCE(SUM(costs), 0), 0) AS costs') ->whereProjectId($projectID) ->first(); return $projectCosts->costs; } }