Implement events for cron expenses; add processing of daily/monthly expenses #136
This commit is contained in:
@@ -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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user