This commit is contained in:
2018-01-25 21:49:30 +01:00
parent fb19c401fd
commit bc0bd51801
16 changed files with 623 additions and 219 deletions
+25
View File
@@ -0,0 +1,25 @@
<?php
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 23/01/2018
* Time: 15:58
*/
class Invoice extends BaseModel {
public function project()
{
return $this->belongsTo( 'Project' );
}
public function payments()
{
return $this->hasMany( 'Payment' );
}
public function vat()
{
return $this->belongsTo( 'Vat' );
}
}
+2 -2
View File
@@ -10,9 +10,9 @@ class Payment extends BaseModel {
protected $table = "payments";
public function offer()
public function invoice()
{
return $this->belongsTo( 'Offer' );
return $this->belongsTo( 'Invoice' );
}
public static function savePayment( $paymentID, $payment )
+14 -5
View File
@@ -21,6 +21,16 @@ class Project extends BaseModel {
return $this->hasMany( 'Projectemployee' );
}
public function projectcosts()
{
return $this->hasMany( 'Projectcost' );
}
public function invoices()
{
return $this->hasMany( 'Invoice' );
}
public function projectleader()
{
return $this->belongsTo( 'User', 'projectleader_id' );
@@ -66,17 +76,16 @@ class Project extends BaseModel {
}] )
->with( [
'offers' => function ( $q ) {
$q->whereArchive( 'F' )
->with( [
'payments' => function ( $q ) {
$q->selectRaw( '*' );
}] );
$q->whereArchive( 'F' );
}] )
->with( [
'projectemployees.user' => function ( $q ) {
$q->selectRaw( "id, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname" );
}] )
->with( 'projectemployees.projecthours' )
->with( 'projectcosts.external' )
->with( 'invoices.payments' )
->with( 'invoices.vat' )
->with( 'customer' );
return $project;
@@ -0,0 +1,21 @@
<?php
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 23/01/2018
* Time: 11:37
*/
class Projectcost extends BaseModel {
public function project()
{
return $this->belongsTo( 'Project' );
}
public function external()
{
return $this->belongsTo( 'External' );
}
}
+30
View File
@@ -0,0 +1,30 @@
<?php
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 23/01/2018
* Time: 19:37
*/
class Vat extends BaseModel {
public function invoices()
{
return $this->hasMany( 'Invoice' );
}
public static function getVats( $archive )
{
if ( $archive == 'F' )
{
$vats = vat::whereArchive( 'F' )->get();
}
else
{
$vats = Vat::get();
}
return $vats;
}
}