hasMany( 'Payment' ); } public function project() { return $this->belongsTo( 'Project' ); } public function customer() { return $this->belongsTo( 'Customer' ); } public static function getAllOffers( $projectID, $archive = 'F' ) { $offers = Offer::orderBy( 'startdate' ) ->with( 'customer' ) ->with( 'project' ); if ( $projectID ) $offers = $offers->whereProjectId( $projectID ); if ( $archive == 'F' ) $offers = $offers->whereArchive( 'F' ); $offers = $offers->get(); return $offers; } public static function getOffersWithoutProject( ) { $offersWithoutProject = Offer::orderBy('startdate') ->whereNull('rejectdate') ->whereNull('project_id') ->get(); return $offersWithoutProject; } public static function saveOffer( $offerID, $offer ) { $offer = (array) $offer; $offer['startdate'] = date2mysql( $offer['startdate'] ); $offer['accepteddate'] = date2mysql( $offer['accepteddate'] ); $offer['rejectdate'] = date2mysql( $offer['rejectdate'] ); if ( $offerID == 0 ) { $offer = Offer::create( $offer ); $offerID = $offer['id']; } else { Offer::whereId( $offerID )->update( $offer ); } return $offerID; } public static function removeOffer( $offerID ) { Offer::whereId( $offerID )->delete(); } }