#11 integrate pjax scaffold for form reload for deleting fares
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Admin;
|
|||||||
use App\Http\Requests\CreateAircraftRequest;
|
use App\Http\Requests\CreateAircraftRequest;
|
||||||
use App\Http\Requests\UpdateAircraftRequest;
|
use App\Http\Requests\UpdateAircraftRequest;
|
||||||
use App\Repositories\AircraftRepository;
|
use App\Repositories\AircraftRepository;
|
||||||
|
use App\Repositories\FareRepository;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Flash;
|
use Flash;
|
||||||
use Prettus\Repository\Criteria\RequestCriteria;
|
use Prettus\Repository\Criteria\RequestCriteria;
|
||||||
@@ -13,10 +14,11 @@ use Response;
|
|||||||
class AircraftController extends BaseController
|
class AircraftController extends BaseController
|
||||||
{
|
{
|
||||||
/** @var AircraftRepository */
|
/** @var AircraftRepository */
|
||||||
private $aircraftRepository;
|
private $aircraftRepository, $fareRepository;
|
||||||
|
|
||||||
public function __construct(AircraftRepository $aircraftRepo)
|
public function __construct(AircraftRepository $aircraftRepo, FareRepository $fareRepo)
|
||||||
{
|
{
|
||||||
|
$this->fareRepository = $fareRepo;
|
||||||
$this->aircraftRepository = $aircraftRepo;
|
$this->aircraftRepository = $aircraftRepo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,7 +67,14 @@ class AircraftController extends BaseController
|
|||||||
return redirect(route('admin.aircraft.index'));
|
return redirect(route('admin.aircraft.index'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return view('admin.aircraft.show')->with('aircraft', $aircraft);
|
$attached_fares = $aircraft->fares;
|
||||||
|
$all_fares = $this->fareRepository->all();
|
||||||
|
$avail_fares = $all_fares->except($attached_fares->modelKeys());
|
||||||
|
|
||||||
|
return view('admin.aircraft.show')
|
||||||
|
->with('aircraft', $aircraft)
|
||||||
|
->with('attached_fares', $attached_fares)
|
||||||
|
->with('avail_fares', $avail_fares);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -121,6 +130,18 @@ class AircraftController extends BaseController
|
|||||||
return redirect(route('admin.aircraft.index'));
|
return redirect(route('admin.aircraft.index'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function return_fares_view($aircraft)
|
||||||
|
{
|
||||||
|
$attached_fares = $aircraft->fares;
|
||||||
|
$all_fares = $this->fareRepository->all();
|
||||||
|
$avail_fares = $all_fares->except($attached_fares->modelKeys());
|
||||||
|
|
||||||
|
return view('admin.aircraft.fares')
|
||||||
|
->with('aircraft', $aircraft)
|
||||||
|
->with('attached_fares', $attached_fares)
|
||||||
|
->with('avail_fares', $avail_fares);
|
||||||
|
}
|
||||||
|
|
||||||
public function fares(Request $request)
|
public function fares(Request $request)
|
||||||
{
|
{
|
||||||
$id = $request->id;
|
$id = $request->id;
|
||||||
@@ -132,12 +153,11 @@ class AircraftController extends BaseController
|
|||||||
|
|
||||||
// associate or dissociate the fare with this aircraft
|
// associate or dissociate the fare with this aircraft
|
||||||
if ($request->isMethod('post') || $request->isMethod('put')) {
|
if ($request->isMethod('post') || $request->isMethod('put')) {
|
||||||
|
// add
|
||||||
} elseif ($request->isMethod('delete')) {
|
} elseif ($request->isMethod('delete')) {
|
||||||
|
print_r($request->request);
|
||||||
}
|
}
|
||||||
|
|
||||||
return view('admin.aircraft.fares')
|
return $this->return_fares_view($aircraft);
|
||||||
->with('fare', $aircraft->fares);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -143,7 +143,8 @@ return [
|
|||||||
'View' => Illuminate\Support\Facades\View::class,
|
'View' => Illuminate\Support\Facades\View::class,
|
||||||
'Form' => Collective\Html\FormFacade::class,
|
'Form' => Collective\Html\FormFacade::class,
|
||||||
'Html' => Collective\Html\HtmlFacade::class,
|
'Html' => Collective\Html\HtmlFacade::class,
|
||||||
'Flash' => Laracasts\Flash\Flash::class
|
'Flash' => Laracasts\Flash\Flash::class,
|
||||||
|
'Yaml' => Symfony\Component\Yaml\Yaml::class,
|
||||||
],
|
],
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -1,22 +1,60 @@
|
|||||||
<table class="table table-responsive" id="aircraft-fares-table">
|
<div id="aircraft_fares_wrapper" class="dataTables_wrapper form-inline dt-bootstrap">
|
||||||
<thead>
|
<table id="aircraft_fares"
|
||||||
<th></th>
|
class="table table-bordered table-hover dataTable"
|
||||||
<th colspan="3">Action</th>
|
role="grid" aria-describedby="aircraft_fares_info">
|
||||||
</thead>
|
<thead>
|
||||||
<tbody>
|
<tr role="row">
|
||||||
@foreach($fares as $fare)
|
<th class="sorting" tabindex="0" aria-controls="aircraft_fares"
|
||||||
<tr>
|
rowspan="1" colspan="1"
|
||||||
<td><a href="{!! route('admin.aircraft.show', [$ac->id]) !!}">{!! $ac->icao !!}</a></td>
|
aria-label="name: activate to sort column ascending">
|
||||||
<td>
|
name
|
||||||
{!! Form::open(['route' => ['admin.aircraft.destroy', $ac->id], 'method' => 'delete']) !!}
|
</th>
|
||||||
<div class='btn-group'>
|
<th class="sorting_asc" tabindex="0"
|
||||||
<a href="{!! route('admin.aircraft.show', [$ac->id]) !!}" class='btn btn-default btn-xs'><i class="glyphicon glyphicon-eye-open"></i></a>
|
aria-controls="aircraft_fares" rowspan="1" colspan="1"
|
||||||
<a href="{!! route('admin.aircraft.edit', [$ac->id]) !!}" class='btn btn-default btn-xs'><i class="glyphicon glyphicon-edit"></i></a>
|
aria-sort="ascending"
|
||||||
{!! Form::button('<i class="glyphicon glyphicon-trash"></i>', ['type' => 'submit', 'class' => 'btn btn-danger btn-xs', 'onclick' => "return confirm('Are you sure?')"]) !!}
|
aria-label="code: activate to sort column descending">
|
||||||
</div>
|
code
|
||||||
{!! Form::close() !!}
|
</th>
|
||||||
</td>
|
<th class="sorting" tabindex="0" aria-controls="aircraft_fares"
|
||||||
</tr>
|
rowspan="1" colspan="1"
|
||||||
@endforeach
|
aria-label="capacity: activate to sort column ascending">
|
||||||
</tbody>
|
capacity
|
||||||
</table>
|
</th>
|
||||||
|
<th class="sorting" tabindex="0" aria-controls="aircraft_fares"
|
||||||
|
rowspan="1" colspan="1"
|
||||||
|
aria-label="price: activate to sort column ascending">
|
||||||
|
price
|
||||||
|
</th>
|
||||||
|
<th class="sorting" tabindex="0" aria-controls="aircraft_fares"
|
||||||
|
rowspan="1" colspan="1"
|
||||||
|
aria-label="cost: activate to sort column ascending">
|
||||||
|
cost
|
||||||
|
</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach($attached_fares as $atf)
|
||||||
|
<tr role="row" class="@if ($loop->iteration%2) even @else odd @endif">
|
||||||
|
<td class="sorting_1">{!! $atf->name !!}</td>
|
||||||
|
<td>{!! $atf->code !!}</td>
|
||||||
|
<td>{!! $atf->capacity !!}</td>
|
||||||
|
<td>{!! $atf->price !!}</td>
|
||||||
|
<td>{!! $atf->cost !!}</td>
|
||||||
|
<td style="text-align: right; width:3%;">
|
||||||
|
<div class='btn-group'>
|
||||||
|
{!! Form::open(['url' => '/admin/aircraft/'.$aircraft->id.'/fares', 'method' => 'delete', 'class' => 'rm_fare']) !!}
|
||||||
|
{!! Form::hidden('fare_id', $atf->id) !!}
|
||||||
|
{!! Form::button('<i class="glyphicon glyphicon-trash"></i>',
|
||||||
|
['type' => 'submit',
|
||||||
|
'class' => 'btn btn-danger btn-s']) !!}
|
||||||
|
{!! Form::close() !!}
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<hr />
|
||||||
|
{!! $avail_fares !!}
|
||||||
|
</div>
|
||||||
|
|||||||
@@ -24,11 +24,13 @@
|
|||||||
|
|
||||||
<!-- Active Field -->
|
<!-- Active Field -->
|
||||||
<div class="form-group col-sm-6">
|
<div class="form-group col-sm-6">
|
||||||
{!! Form::label('active', 'Active:') !!}
|
<div class="checkbox">
|
||||||
<label class="checkbox-inline">
|
<label class="checkbox-inline">
|
||||||
{!! Form::hidden('active', false) !!}
|
{!! Form::hidden('active', false) !!}
|
||||||
{!! Form::checkbox('active', '1', true) !!}
|
{!! Form::checkbox('active', '1', true) !!}
|
||||||
</label>
|
{!! Form::label('active', 'Active') !!}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Submit Field -->
|
<!-- Submit Field -->
|
||||||
@@ -36,3 +38,8 @@
|
|||||||
{!! Form::submit('Save', ['class' => 'btn btn-primary']) !!}
|
{!! Form::submit('Save', ['class' => 'btn btn-primary']) !!}
|
||||||
<a href="{!! route('admin.aircraft.index') !!}" class="btn btn-default">Cancel</a>
|
<a href="{!! route('admin.aircraft.index') !!}" class="btn btn-default">Cancel</a>
|
||||||
</div>
|
</div>
|
||||||
|
<script>
|
||||||
|
jQuery('input#active').iCheck('check');
|
||||||
|
//$(document).ready(function() {
|
||||||
|
//})
|
||||||
|
</script>
|
||||||
|
|||||||
@@ -1,19 +1,34 @@
|
|||||||
@extends('admin.app')
|
@extends('admin.app')
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<section class="content-header">
|
<section class="content-header"><h1>{!! $aircraft->name !!}</section>
|
||||||
<h1>
|
<section class="content">
|
||||||
Aircraft
|
<div class="row">
|
||||||
</h1>
|
@include('admin.aircraft.show_fields')
|
||||||
</section>
|
</div>
|
||||||
<div class="content">
|
<div class="box box-primary">
|
||||||
<div class="box box-primary">
|
<div class="box-body">
|
||||||
<div class="box-body">
|
<div class="row">
|
||||||
<div class="row" style="padding-left: 20px">
|
<div class="col-xs-12">
|
||||||
@include('admin.aircraft.show_fields')
|
<hr/>
|
||||||
<a href="{!! route('admin.aircraft.index') !!}" class="btn btn-default">Back</a>
|
<h3 class="box-header">fares</h3>
|
||||||
|
<div class="box-body">
|
||||||
|
@include('admin.aircraft.fares')
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</section>
|
||||||
|
@endsection
|
||||||
|
@section('scripts')
|
||||||
|
<script>
|
||||||
|
$(document).ready(function() {
|
||||||
|
$(document).on('submit', 'form.rm_fare', function(event) {
|
||||||
|
console.log('saving!');
|
||||||
|
event.preventDefault();
|
||||||
|
$.pjax.submit(event, '#aircraft_fares_wrapper', {push: false});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
@endsection
|
@endsection
|
||||||
|
|||||||
@@ -1,36 +1,43 @@
|
|||||||
<!-- Icao Field -->
|
<!-- Icao Field -->
|
||||||
<div class="form-group col-sm-6">
|
<div class="form-group col-sm-6">
|
||||||
{!! Form::label('icao', 'ICAO:') !!}
|
<div class="box box-solid">
|
||||||
<p>{!! $aircraft->icao !!}</p>
|
<div class="box-header with-border">
|
||||||
|
{{--<i class="fa fa-text-width"></i>--}}
|
||||||
|
<h3 class="box-title">{!! Form::label('icao', 'ICAO:') !!}</h3>
|
||||||
|
</div>
|
||||||
|
<div class="box-body"><p class="lead">{!! $aircraft->icao !!}</p></div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Name Field -->
|
<!-- Name Field -->
|
||||||
<div class="form-group col-sm-6">
|
<div class="form-group col-sm-6">
|
||||||
{!! Form::label('name', 'Name:') !!}
|
<div class="box box-solid">
|
||||||
<p>{!! $aircraft->name !!}</p>
|
<div class="box-header with-border">
|
||||||
|
{{--<i class="fa fa-text-width"></i>--}}
|
||||||
|
<h3 class="box-title">{!! Form::label('name', 'Name:') !!}</h3>
|
||||||
|
</div>
|
||||||
|
<div class="box-body"><p class="lead">{!! $aircraft->name !!}</p></div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Registration Field -->
|
<!-- Registration Field -->
|
||||||
<div class="form-group col-sm-6">
|
<div class="form-group col-sm-6">
|
||||||
{!! Form::label('registration', 'Registration:') !!}
|
<div class="box box-solid">
|
||||||
<p>{!! $aircraft->registration !!}</p>
|
<div class="box-header with-border">
|
||||||
|
{{--<i class="fa fa-text-width"></i>--}}
|
||||||
|
<h3 class="box-title">{!! Form::label('registration', 'Registration:') !!}</h3>
|
||||||
|
</div>
|
||||||
|
<div class="box-body"><p class="lead">{!! $aircraft->registration !!}</p></div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Active Field -->
|
<!-- Active Field -->
|
||||||
<div class="form-group col-sm-6">
|
<div class="form-group col-sm-6">
|
||||||
{!! Form::label('active', 'Active:') !!}
|
<div class="box box-solid">
|
||||||
<p>{!! $aircraft->active !!}</p>
|
<div class="box-header with-border">
|
||||||
|
{{--<i class="fa fa-text-width"></i>--}}
|
||||||
|
<h3 class="box-title">{!! Form::label('active', 'Active:') !!}</h3>
|
||||||
|
</div>
|
||||||
|
<div class="box-body"><p class="lead">@if ($aircraft->active == '1') yes @else no @endif</p></div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Created At Field -->
|
|
||||||
<div class="form-group col-sm-6">
|
|
||||||
{!! Form::label('created_at', 'Created At:') !!}
|
|
||||||
<p>{!! $aircraft->created_at !!}</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Updated At Field -->
|
|
||||||
<div class="form-group col-sm-6">
|
|
||||||
{!! Form::label('updated_at', 'Updated At:') !!}
|
|
||||||
<p>{!! $aircraft->updated_at !!}</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|||||||
@@ -174,10 +174,11 @@
|
|||||||
@endif
|
@endif
|
||||||
|
|
||||||
<!-- jQuery 2.1.4 -->
|
<!-- jQuery 2.1.4 -->
|
||||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
|
||||||
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
|
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.2/js/select2.min.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.2/js/select2.min.js"></script>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/iCheck/1.0.2/icheck.min.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/iCheck/1.0.2/icheck.min.js"></script>
|
||||||
|
<script src="/vendor/pjax/jquery.pjax.js"></script>
|
||||||
|
|
||||||
<!-- AdminLTE App -->
|
<!-- AdminLTE App -->
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/admin-lte/2.3.3/js/app.min.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/admin-lte/2.3.3/js/app.min.js"></script>
|
||||||
|
|||||||
Reference in New Issue
Block a user