Implement events for cron expenses; add processing of daily/monthly expenses #136

This commit is contained in:
Nabeel Shahzad
2018-03-16 20:12:56 -05:00
parent d34de098e5
commit 067fb0f9f0
24 changed files with 623 additions and 118 deletions

View File

@@ -4,8 +4,11 @@ namespace App\Models;
/**
* Class Expense
* @property int airline_id
* @property float amount
* @property string name
* @property string ref_class
* @property string ref_class_id
* @package App\Models
*/
class Expense extends BaseModel
@@ -33,6 +36,27 @@ class Expense extends BaseModel
'charge_to_user' => 'bool',
];
/**
* Get the referring object
*/
public function getReference()
{
if (!$this->ref_class || !$this->ref_class_id) {
return null;
}
if($this->ref_class === __CLASS__) {
return $this;
}
try {
$klass = new $this->ref_class;
return $klass->find($this->ref_class_id);
} catch (\Exception $e) {
return null;
}
}
/**
* Foreign Keys
*/