Convert expense type to char, translations for ExpenseType

This commit is contained in:
Nabeel Shahzad
2018-04-01 22:26:20 -05:00
parent 2a01a935c0
commit cfd0853d79
12 changed files with 78 additions and 65 deletions

View File

@@ -5,7 +5,7 @@ namespace App\Models\Traits;
/**
* Trait ReferenceTrait
* @property \App\Interfaces\Model $ref_model
* @property mixed $ref_model_id
* @property mixed $ref_model_id
* @package App\Models\Traits
*/
trait ReferenceTrait
@@ -29,12 +29,20 @@ trait ReferenceTrait
*/
public function getReferencedObject()
{
if ($classname = $this->ref_model) {
$klass = new $this->ref_model;
return $klass->find($this->ref_model_id);
if (!$this->ref_model || !$this->ref_model_id) {
return null;
}
return null;
if ($this->ref_model === __CLASS__) {
return $this;
}
try {
$klass = new $this->ref_model;
$obj = $klass->find($this->ref_model_id);
return $obj;
} catch (\Exception $e) {
return null;
}
}
}