diff --git a/app/Http/Controllers/Admin/AircraftController.php b/app/Http/Controllers/Admin/AircraftController.php new file mode 100644 index 00000000..2412a055 --- /dev/null +++ b/app/Http/Controllers/Admin/AircraftController.php @@ -0,0 +1,123 @@ +aircraftRepository = $aircraftRepo; + } + + /** + * Display a listing of the Aircraft. + */ + public function index(Request $request) + { + $this->aircraftRepository->pushCriteria(new RequestCriteria($request)); + $aircraft = $this->aircraftRepository->all(); + + return view('admin.aircraft.index') + ->with('aircraft', $aircraft); + } + + /** + * Show the form for creating a new Aircraft. + */ + public function create() + { + return view('admin.aircraft.create'); + } + + /** + * Store a newly created Aircraft in storage. + */ + public function store(CreateAircraftRequest $request) + { + $input = $request->all(); + + $aircraft = $this->aircraftRepository->create($input); + + Flash::success('Aircraft saved successfully.'); + return redirect(route('admin.aircraft.index')); + } + + /** + * Display the specified Aircraft. + */ + public function show($id) + { + $aircraft = $this->aircraftRepository->findWithoutFail($id); + + if (empty($aircraft)) { + Flash::error('Aircraft not found'); + return redirect(route('admin.aircraft.index')); + } + + return view('admin.aircraft.show')->with('aircraft', $aircraft); + } + + /** + * Show the form for editing the specified Aircraft. + */ + public function edit($id) + { + $aircraft = $this->aircraftRepository->findWithoutFail($id); + + if (empty($aircraft)) { + Flash::error('Aircraft not found'); + return redirect(route('admin.aircraft.index')); + } + + return view('admin.aircraft.edit')->with('aircraft', $aircraft); + } + + /** + * Update the specified Aircraft in storage. + */ + public function update($id, UpdateAircraftRequest $request) + { + $aircraft = $this->aircraftRepository->findWithoutFail($id); + + if (empty($aircraft)) { + Flash::error('Aircraft not found'); + return redirect(route('admin.aircraft.index')); + } + + $aircraft = $this->aircraftRepository->update($request->all(), $id); + + Flash::success('Aircraft updated successfully.'); + + return redirect(route('admin.aircraft.index')); + } + + /** + * Remove the specified Aircraft from storage. + */ + public function destroy($id) + { + $aircraft = $this->aircraftRepository->findWithoutFail($id); + + if (empty($aircraft)) { + Flash::error('Aircraft not found'); + return redirect(route('admin.aircraft.index')); + } + + $this->aircraftRepository->delete($id); + + Flash::success('Aircraft deleted successfully.'); + + return redirect(route('admin.aircraft.index')); + } +} diff --git a/app/Http/Requests/CreateAircraftRequest.php b/app/Http/Requests/CreateAircraftRequest.php new file mode 100644 index 00000000..4501c0f5 --- /dev/null +++ b/app/Http/Requests/CreateAircraftRequest.php @@ -0,0 +1,30 @@ + 'string', + 'name' => 'string', + 'full_name' => 'string', + 'registration' => 'string', + 'active' => 'boolean', + ]; + + /** + * Validation rules + * + * @var array + */ + public static $rules = [ + 'icao' => 'required|max:4', + 'name' => 'required', + 'full_name' => 'required', + 'registration' => 'required', + ]; +} diff --git a/app/Repositories/AircraftRepository.php b/app/Repositories/AircraftRepository.php new file mode 100644 index 00000000..468e23c8 --- /dev/null +++ b/app/Repositories/AircraftRepository.php @@ -0,0 +1,28 @@ +increments('id'); + $table->string('icao'); + $table->string('name'); + $table->string('full_name')->nullable(); + $table->string('registration')->nullable(); + $table->boolean('active'); + $table->timestamps(); + $table->softDeletes(); + }); + } + + public function down() + { + Schema::drop('aircraft'); + } +} diff --git a/resources/views/admin/aircraft/create.blade.php b/resources/views/admin/aircraft/create.blade.php new file mode 100644 index 00000000..8d27dceb --- /dev/null +++ b/resources/views/admin/aircraft/create.blade.php @@ -0,0 +1,24 @@ +@extends('admin.app') + +@section('content') +
+

+ Aircraft +

+
+
+ @include('adminlte-templates::common.errors') +
+ +
+
+ {!! Form::open(['route' => 'admin.aircraft.store']) !!} + + @include('admin.aircraft.fields') + + {!! Form::close() !!} +
+
+
+
+@endsection diff --git a/resources/views/admin/aircraft/edit.blade.php b/resources/views/admin/aircraft/edit.blade.php new file mode 100644 index 00000000..e55d3b7e --- /dev/null +++ b/resources/views/admin/aircraft/edit.blade.php @@ -0,0 +1,23 @@ +@extends('admin.app') + +@section('content') +
+

+ Aircraft +

+
+
+ @include('adminlte-templates::common.errors') +
+
+
+ {!! Form::model($aircraft, ['route' => ['admin.aircraft.update', $aircraft->id], 'method' => 'patch']) !!} + + @include('admin.aircraft.fields') + + {!! Form::close() !!} +
+
+
+
+@endsection diff --git a/resources/views/admin/aircraft/fields.blade.php b/resources/views/admin/aircraft/fields.blade.php new file mode 100644 index 00000000..f9ee41f0 --- /dev/null +++ b/resources/views/admin/aircraft/fields.blade.php @@ -0,0 +1,38 @@ + +
+ {!! Form::label('icao', 'ICAO:') !!} + {!! Form::text('icao', null, ['class' => 'form-control']) !!} +
+ + +
+ {!! Form::label('name', 'Name:') !!} + {!! Form::text('name', null, ['class' => 'form-control']) !!} +
+ + +
+ {!! Form::label('full_name', 'Full Name:') !!} + {!! Form::text('full_name', null, ['class' => 'form-control']) !!} +
+ + +
+ {!! Form::label('registration', 'Registration:') !!} + {!! Form::text('registration', null, ['class' => 'form-control']) !!} +
+ + +
+ {!! Form::label('active', 'Active:') !!} + +
+ + +
+ {!! Form::submit('Save', ['class' => 'btn btn-primary']) !!} + Cancel +
diff --git a/resources/views/admin/aircraft/index.blade.php b/resources/views/admin/aircraft/index.blade.php new file mode 100644 index 00000000..1790e313 --- /dev/null +++ b/resources/views/admin/aircraft/index.blade.php @@ -0,0 +1,23 @@ +@extends('admin.app') + +@section('content') +
+

Aircraft

+

+ Add New +

+
+
+
+ + @include('flash::message') + +
+
+
+ @include('admin.aircraft.table') +
+
+
+@endsection + diff --git a/resources/views/admin/aircraft/show.blade.php b/resources/views/admin/aircraft/show.blade.php new file mode 100644 index 00000000..1e3d82e9 --- /dev/null +++ b/resources/views/admin/aircraft/show.blade.php @@ -0,0 +1,19 @@ +@extends('admin.app') + +@section('content') +
+

+ Aircraft +

+
+
+
+
+
+ @include('admin.aircraft.show_fields') + Back +
+
+
+
+@endsection diff --git a/resources/views/admin/aircraft/show_fields.blade.php b/resources/views/admin/aircraft/show_fields.blade.php new file mode 100644 index 00000000..e225efa6 --- /dev/null +++ b/resources/views/admin/aircraft/show_fields.blade.php @@ -0,0 +1,48 @@ + +
+ {!! Form::label('id', 'ID:') !!} +

{!! $aircraft->id !!}

+
+ + +
+ {!! Form::label('icao', 'ICAO:') !!} +

{!! $aircraft->icao !!}

+
+ + +
+ {!! Form::label('name', 'Name:') !!} +

{!! $aircraft->name !!}

+
+ + +
+ {!! Form::label('full_name', 'Full Name:') !!} +

{!! $aircraft->full_name !!}

+
+ + +
+ {!! Form::label('registration', 'Registration:') !!} +

{!! $aircraft->registration !!}

+
+ + +
+ {!! Form::label('active', 'Active:') !!} +

{!! $aircraft->active !!}

+
+ + +
+ {!! Form::label('created_at', 'Created At:') !!} +

{!! $aircraft->created_at !!}

+
+ + +
+ {!! Form::label('updated_at', 'Updated At:') !!} +

{!! $aircraft->updated_at !!}

+
+ diff --git a/resources/views/admin/aircraft/table.blade.php b/resources/views/admin/aircraft/table.blade.php new file mode 100644 index 00000000..fb22e2f9 --- /dev/null +++ b/resources/views/admin/aircraft/table.blade.php @@ -0,0 +1,28 @@ + + + + + + + + + + @foreach($aircraft as $ac) + + + + + + + + @endforeach + +
ICAONameRegistrationActiveAction
{!! $ac->icao !!}{!! $ac->name !!}{!! $ac->registration !!}{!! $ac->active !!} + {!! Form::open(['route' => ['admin.aircraft.destroy', $ac->id], 'method' => 'delete']) !!} +
+ + + {!! Form::button('', ['type' => 'submit', 'class' => 'btn btn-danger btn-xs', 'onclick' => "return confirm('Are you sure?')"]) !!} +
+ {!! Form::close() !!} +