Offers
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user