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

@@ -2,6 +2,7 @@
namespace App\Models;
use App\Interfaces\Model;
use App\Models\Traits\ReferenceTrait;
/**
* Class Expense
@@ -14,6 +15,8 @@ use App\Interfaces\Model;
*/
class Expense extends Model
{
use ReferenceTrait;
public $table = 'expenses';
protected $fillable = [
@@ -32,33 +35,10 @@ class Expense extends Model
'active' => 'boolean',
'airline_id' => 'integer',
'amount' => 'float',
'type' => 'integer',
'multiplier' => 'bool',
'charge_to_user' => 'bool',
];
/**
* Get the referring object
*/
public function getReference()
{
if (!$this->ref_model || !$this->ref_model_id) {
return null;
}
if ($this->ref_model === __CLASS__) {
return $this;
}
try {
$klass = new $this->ref_model;
return $klass->find($this->ref_model_id);
} catch (\Exception $e) {
return null;
}
}
/**
* Foreign Keys
*/