This commit is contained in:
2018-01-10 14:09:34 +01:00
parent d1de2210e6
commit 6366bbc6a8
19 changed files with 776 additions and 162 deletions
+44 -1
View File
@@ -8,7 +8,7 @@
use \Illuminate\Database\Eloquent\Model as Eloquent;
class Page extends Eloquent {
class Offer extends BaseModel {
protected $table = "offers";
@@ -16,4 +16,47 @@ class Page extends Eloquent {
{
return $this->belongsTo( 'Project' );
}
public function customer()
{
return $this->belongsTo( 'Customer' );
}
public static function getAllOffers( $archive = 'F' )
{
$offers = Offer::orderBy('startdate')
->with( 'customer' )
->with( 'project' );
if ( $archive == 'F' ) $offers = $offers->whereArchive( 'F' );
$offers = $offers->get();
return $offers;
}
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 );
}
else
{
$offer = Offer::whereId( $offerID )->update( $offer );
}
return $offer['id'];
}
public static function removeOffer( $offerID )
{
Offer::whereId($offerID)->delete();
}
}