project
This commit is contained in:
@@ -11,6 +11,11 @@ class Offer extends BaseModel {
|
||||
|
||||
protected $table = "offers";
|
||||
|
||||
public function payments()
|
||||
{
|
||||
return $this->hasMany( 'Payment' );
|
||||
}
|
||||
|
||||
public function project()
|
||||
{
|
||||
return $this->belongsTo( 'Project' );
|
||||
@@ -23,7 +28,7 @@ class Offer extends BaseModel {
|
||||
|
||||
public static function getAllOffers( $archive = 'F' )
|
||||
{
|
||||
$offers = Offer::orderBy('startdate')
|
||||
$offers = Offer::orderBy( 'startdate' )
|
||||
->with( 'customer' )
|
||||
->with( 'project' );
|
||||
|
||||
@@ -56,6 +61,6 @@ class Offer extends BaseModel {
|
||||
|
||||
public static function removeOffer( $offerID )
|
||||
{
|
||||
Offer::whereId($offerID)->delete();
|
||||
Offer::whereId( $offerID )->delete();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 16/01/2018
|
||||
* Time: 10:27
|
||||
*/
|
||||
|
||||
class Payment extends BaseModel {
|
||||
|
||||
protected $table = "projects";
|
||||
|
||||
public function offer()
|
||||
{
|
||||
return $this->belongsTo( 'Offer' );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -32,12 +32,25 @@ class Project extends BaseModel {
|
||||
'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');
|
||||
if ( $archive == 'F' ) $projects = $projects->whereArchive( 'F' );
|
||||
|
||||
$projects = $projects->get();
|
||||
|
||||
return $projects;
|
||||
}
|
||||
|
||||
public static function removeProject( $projectID )
|
||||
{
|
||||
Project::whereId($projectID)->delete();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user