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') +
{!! $award->title !!}
+{!! $award->description !!}
+