Convert expense type to char, translations for ExpenseType
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user