46 lines
819 B
PHP
46 lines
819 B
PHP
<?php
|
|
/**
|
|
* Created by Pensare Software.
|
|
* User: Theo Weijmer
|
|
* Date: 10/06/2018
|
|
* Time: 15:56
|
|
*/
|
|
|
|
class RemoveInvoices {
|
|
|
|
private $invoiceID;
|
|
private $payments;
|
|
private $removeAllowed;
|
|
|
|
public function __construct( $invoiceID )
|
|
{
|
|
$this->setInvoiceID($invoiceID);
|
|
|
|
$this->handle();
|
|
}
|
|
|
|
private function setInvoiceID( $invoiceID )
|
|
{
|
|
$this->invoiceID = $invoiceID;
|
|
}
|
|
|
|
private function handle()
|
|
{
|
|
$this->setPayments();
|
|
|
|
$this->setRemoveAllowed();
|
|
}
|
|
|
|
private function setPayments()
|
|
{
|
|
$payments = Payment::whereInvoiceId($this->invoiceID);
|
|
|
|
$this->payments = $payments->count() == 0 ? TRUE : FALSE;
|
|
}
|
|
|
|
private function setRemoveAllowed()
|
|
{
|
|
$this->removeAllowed = $this->payments;
|
|
}
|
|
|
|
} |