diff --git a/app/Database/migrations/2018_01_28_180522_create_awards_table.php b/app/Database/migrations/2018_01_28_180522_create_awards_table.php new file mode 100644 index 00000000..b0c951fd --- /dev/null +++ b/app/Database/migrations/2018_01_28_180522_create_awards_table.php @@ -0,0 +1,34 @@ +increments('id'); + $table->string('title', 50); + $table->text('description', 50)->nullable(); + $table->string('image', 255)->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('awards'); + } +} diff --git a/app/Http/Controllers/Admin/AwardController.php b/app/Http/Controllers/Admin/AwardController.php new file mode 100755 index 00000000..733e54fd --- /dev/null +++ b/app/Http/Controllers/Admin/AwardController.php @@ -0,0 +1,143 @@ +awardRepository = $awardRepo; + } + + /** + * Display a listing of the Fare. + * + * @param Request $request + * + * @return Response + */ + public function index(Request $request) + { + $this->awardRepository->pushCriteria(new RequestCriteria($request)); + $awards = $this->awardRepository->all(); + + return view('admin.awards.index') + ->with('awards', $awards); + } + + /** + * Show the form for creating a new Fare. + * + * @return Response + */ + public function create() + { + return view('admin.awards.create'); + } + + /** + * Store a newly created Fare in storage. + * + * @param CreateFareRequest $request + * + * @return Response + */ + public function store(CreateAwardRequest $request) + { + $input = $request->all(); + $award = $this->awardRepository->create($input); + Flash::success('Award saved successfully.'); + + return redirect(route('admin.awards.index')); + } + + /** + * Display the specified Fare. + * + * @param int $id + * + * @return Response + */ + public function show($id) + { + $fare = $this->awardRepository->findWithoutFail($id); + if (empty($award)) { + Flash::error('Award not found'); + return redirect(route('admin.awards.index')); + } + + return view('admin.awards.show')->with('award', $award); + } + + /** + * Show the form for editing the specified Fare. + * + * @param int $id + * + * @return Response + */ + public function edit($id) + { + $award = $this->awardRepository->findWithoutFail($id); + if (empty($award)) { + Flash::error('Award not found'); + return redirect(route('admin.awards.index')); + } + + return view('admin.awards.edit')->with('award', $award); + } + + /** + * Update the specified Fare in storage. + * + * @param int $id + * @param UpdateFareRequest $request + * + * @return Response + */ + public function update($id, UpdateAwardRequest $request) + { + $award = $this->awardRepository->findWithoutFail($id); + if (empty($award)) { + Flash::error('Award not found'); + return redirect(route('admin.awards.index')); + } + + $award = $this->awardRepository->update($request->all(), $id); + Flash::success('Award updated successfully.'); + + return redirect(route('admin.awards.index')); + } + + /** + * Remove the specified Fare from storage. + * + * @param int $id + * + * @return Response + */ + public function destroy($id) + { + $award = $this->awardRepository->findWithoutFail($id); + if (empty($award)) { + Flash::error('Fare not found'); + return redirect(route('admin.awards.index')); + } + + $this->awardRepository->delete($id); + Flash::success('Fare deleted successfully.'); + + return redirect(route('admin.awards.index')); + } +} diff --git a/app/Http/Requests/CreateAwardRequest.php b/app/Http/Requests/CreateAwardRequest.php new file mode 100755 index 00000000..507ba140 --- /dev/null +++ b/app/Http/Requests/CreateAwardRequest.php @@ -0,0 +1,30 @@ + $this->id, + 'title' => $this->title, + 'description' => $this->description, + 'image' => $this->image, + ]; + } +} diff --git a/app/Models/Award.php b/app/Models/Award.php new file mode 100755 index 00000000..078303be --- /dev/null +++ b/app/Models/Award.php @@ -0,0 +1,38 @@ + 'required', + ]; + + + /** + * any foreign keys + */ + /* + public function subfleets() { + return $this->belongsToMany(Subfleet::class, 'subfleet_fare') + ->withPivot('price', 'cost', 'capacity'); + } + */ +} diff --git a/app/Repositories/AwardRepository.php b/app/Repositories/AwardRepository.php new file mode 100755 index 00000000..5842982d --- /dev/null +++ b/app/Repositories/AwardRepository.php @@ -0,0 +1,25 @@ + 'like', + ]; + + public function model() + { + return Award::class; + } + + public function findByTitle($title) { + return $this->findByField('title', $title)->first(); + } +} diff --git a/app/Routes/admin.php b/app/Routes/admin.php index f2108873..5bd7b12d 100644 --- a/app/Routes/admin.php +++ b/app/Routes/admin.php @@ -13,6 +13,9 @@ Route::group([ Route::resource('airports', 'AirportController'); Route::match(['get', 'post', 'put', 'delete'], 'airports/{id}/expenses', 'AirportController@expenses'); + # Awards + Route::resource('awards', 'AwardController'); + # aircraft and fare associations Route::resource('aircraft', 'AircraftController'); Route::match(['get', 'post', 'put', 'delete'], 'aircraft/{id}/expenses', 'AircraftController@expenses'); diff --git a/resources/views/admin/awards/create.blade.php b/resources/views/admin/awards/create.blade.php new file mode 100755 index 00000000..6a6a8c2b --- /dev/null +++ b/resources/views/admin/awards/create.blade.php @@ -0,0 +1,11 @@ +@extends('admin.app') +@section('title', 'Add Award') +@section('content') +
+
+ {!! Form::open(['route' => 'admin.awards.store']) !!} + @include('admin.awards.fields') + {!! Form::close() !!} +
+
+@endsection diff --git a/resources/views/admin/awards/edit.blade.php b/resources/views/admin/awards/edit.blade.php new file mode 100755 index 00000000..85058e75 --- /dev/null +++ b/resources/views/admin/awards/edit.blade.php @@ -0,0 +1,11 @@ +@extends('admin.app') +@section('title', "Edit \"$award->title\" Award") +@section('content') +
+
+ {!! Form::model($award, ['route' => ['admin.awards.update', $award->id], 'method' => 'patch']) !!} + @include('admin.awards.fields') + {!! Form::close() !!} +
+
+@endsection diff --git a/resources/views/admin/awards/fields.blade.php b/resources/views/admin/awards/fields.blade.php new file mode 100755 index 00000000..88bcfb86 --- /dev/null +++ b/resources/views/admin/awards/fields.blade.php @@ -0,0 +1,46 @@ +
+
+
+ Awards that can be granted to pilots. +
+
+
+
+
+
+ {!! Form::label('title', 'Title:') !!} * +
+    + This will be the title of the award +
+ {!! Form::text('title', null, ['class' => 'form-control']) !!} +
+ + + +
+ {!! Form::label('image', 'Image:') !!} +
+    + This is the image of the award. Be creative! +
+ {!! Form::text('image', null, ['class' => 'form-control', 'placeholder' => 'Enter the url of the image location']) !!} +
+ +
+ {!! Form::label('description', 'Description:') !!}  +
+    + This is the description of the award. +
+ {!! Form::textarea('description', null, ['class' => 'form-control']) !!} +
+ + +
+
+ {!! Form::button('Save', ['type' => 'submit', 'class' => 'btn btn-success']) !!} + Cancel +
+
+
diff --git a/resources/views/admin/awards/index.blade.php b/resources/views/admin/awards/index.blade.php new file mode 100755 index 00000000..2afaa32c --- /dev/null +++ b/resources/views/admin/awards/index.blade.php @@ -0,0 +1,18 @@ +@extends('admin.app') + +@section('title', 'Awards') +@section('actions') +
  • + + + Add New + +
  • +@endsection + +@section('content') +
    + @include('admin.awards.table') +
    +@endsection + diff --git a/resources/views/admin/awards/show.blade.php b/resources/views/admin/awards/show.blade.php new file mode 100755 index 00000000..a2da501a --- /dev/null +++ b/resources/views/admin/awards/show.blade.php @@ -0,0 +1,9 @@ +@extends('admin.app') + +@section('content') +
    +
    + @include('admin.awards.show_fields') +
    +
    +@endsection diff --git a/resources/views/admin/awards/show_fields.blade.php b/resources/views/admin/awards/show_fields.blade.php new file mode 100755 index 00000000..bdf1eff6 --- /dev/null +++ b/resources/views/admin/awards/show_fields.blade.php @@ -0,0 +1,17 @@ + +
    + {!! Form::label('title', 'Title:') !!} +

    {!! $award->title !!}

    +
    + + +
    + {!! Form::label('Description', 'Description:') !!} +

    {!! $award->description !!}

    +
    + + +
    + {!! Form::label('image', 'Image:') !!} +

    No Image Available

    +
    \ No newline at end of file diff --git a/resources/views/admin/awards/table.blade.php b/resources/views/admin/awards/table.blade.php new file mode 100755 index 00000000..9b05a53d --- /dev/null +++ b/resources/views/admin/awards/table.blade.php @@ -0,0 +1,23 @@ + + + + + + + + + @foreach($awards as $award) + + + + + + + @endforeach + +
    TitleDescriptionImageAction
    {!! $award->title !!}{!! $award->description !!}No Image Available + {!! Form::open(['route' => ['admin.awards.destroy', $award->id], 'method' => 'delete']) !!} + + {!! Form::button('', ['type' => 'submit', 'class' => 'btn btn-sm btn-danger btn-icon', 'onclick' => "return confirm('Are you sure you want to delete this award?')"]) !!} + {!! Form::close() !!} +
    diff --git a/resources/views/admin/menu.blade.php b/resources/views/admin/menu.blade.php index 5c6b5a67..848c4464 100644 --- a/resources/views/admin/menu.blade.php +++ b/resources/views/admin/menu.blade.php @@ -37,6 +37,7 @@
  • expenses
  • users
  • ranks
  • +
  • awards
  • settings