This commit is contained in:
2018-01-16 13:36:59 +01:00
parent 97f1b988bc
commit 00246f49f7
10 changed files with 248 additions and 41 deletions
+7 -2
View File
@@ -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();
}
}
+18
View File
@@ -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' );
}
}
+14 -1
View File
@@ -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();
}
}