Add finance controller; morphable expense type so they can be applied to any model #130
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Traits\ExpensableTrait;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
/**
|
||||
@@ -11,6 +12,7 @@ use Illuminate\Notifications\Notifiable;
|
||||
*/
|
||||
class Airport extends BaseModel
|
||||
{
|
||||
use ExpensableTrait;
|
||||
use Notifiable;
|
||||
|
||||
public $table = 'airports';
|
||||
|
||||
28
app/Models/Traits/ExpensableTrait.php
Normal file
28
app/Models/Traits/ExpensableTrait.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Traits;
|
||||
|
||||
use App\Models\Expense;
|
||||
|
||||
trait ExpensableTrait
|
||||
{
|
||||
|
||||
/**
|
||||
* Initialize a new journal when a new record is created
|
||||
*/
|
||||
public static function bootExpensableTrait()
|
||||
{
|
||||
/*static::created(function ($model) {
|
||||
$model->initJournal(config('phpvms.currency'));
|
||||
});*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Morph to Expenses.
|
||||
* @return mixed
|
||||
*/
|
||||
public function expenses()
|
||||
{
|
||||
return $this->morphToMany(Expense::class, 'expensable');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user