2018-03-06 04:18:54 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models\Traits;
|
|
|
|
|
|
|
|
use App\Models\Expense;
|
|
|
|
|
2018-03-06 11:24:49 +08:00
|
|
|
trait Expensable
|
2018-03-06 04:18:54 +08:00
|
|
|
{
|
2018-03-06 11:24:49 +08:00
|
|
|
public static function bootExpensable()
|
2018-03-06 04:18:54 +08:00
|
|
|
{
|
2018-03-06 12:10:00 +08:00
|
|
|
|
2018-03-06 04:18:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Morph to Expenses.
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function expenses()
|
|
|
|
{
|
2018-03-06 12:10:00 +08:00
|
|
|
return $this->morphMany(
|
|
|
|
Expense::class,
|
|
|
|
'expenses', # overridden by the next two anyway
|
|
|
|
'ref_class',
|
|
|
|
'ref_class_id'
|
|
|
|
);
|
2018-03-06 04:18:54 +08:00
|
|
|
}
|
|
|
|
}
|