Add finance controller; morphable expense type so they can be applied to any model #130
This commit is contained in:
parent
33c2ee702b
commit
53e4bf533f
@ -20,7 +20,11 @@ class CreateExpensesTable extends Migration
|
||||
$table->unsignedInteger('amount');
|
||||
$table->unsignedTinyInteger('type');
|
||||
$table->boolean('multiplier')->nullable()->default(0);
|
||||
$table->boolean('active')->nullable()->default(1);
|
||||
$table->boolean('active')->nullable()->default(true);
|
||||
|
||||
# Internal fields are expenses tied to some system object
|
||||
# EG, the airports has an internal expense for gate costs
|
||||
$table->nullableMorphs('expensable');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
46
app/Http/Controllers/Admin/FinanceController.php
Normal file
46
app/Http/Controllers/Admin/FinanceController.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Repositories\JournalRepository;
|
||||
use App\Services\FinanceService;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
* Class FinanceController
|
||||
* @package App\Http\Controllers\Admin
|
||||
*/
|
||||
class FinanceController extends BaseController
|
||||
{
|
||||
private $financeSvc,
|
||||
$journalRepo;
|
||||
|
||||
/**
|
||||
* AircraftController constructor.
|
||||
* @param FinanceService $financeSvc
|
||||
* @param JournalRepository $journalRepo
|
||||
*/
|
||||
public function __construct(
|
||||
FinanceService $financeSvc,
|
||||
JournalRepository $journalRepo
|
||||
) {
|
||||
$this->financeSvc = $financeSvc;
|
||||
$this->journalRepo = $journalRepo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the Aircraft.
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a month
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -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');
|
||||
}
|
||||
}
|
@ -21,6 +21,9 @@ Route::group([
|
||||
# fares
|
||||
Route::resource('fares', 'FareController');
|
||||
|
||||
# finances
|
||||
Route::resource('finances', 'FinanceController');
|
||||
|
||||
# flights and aircraft associations
|
||||
Route::resource('flights', 'FlightController');
|
||||
Route::match(['get', 'post', 'put', 'delete'], 'flights/{id}/fares', 'FlightController@fares');
|
||||
|
@ -18,6 +18,7 @@
|
||||
<li><a href="{!! url('/admin/flights') !!}"><i class="pe-7s-vector"></i>flights</a></li>
|
||||
<li><a href="{!! url('/admin/aircraft') !!}"><i class="pe-7s-plane"></i>fleet</a></li>
|
||||
<li><a href="{!! url('/admin/fares') !!}"><i class="pe-7s-graph2"></i>fares</a></li>
|
||||
<li><a href="{!! url('/admin/fares') !!}"><i class="pe-7s-display1"></i>finances</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
|
Loading…
Reference in New Issue
Block a user