diff --git a/app/Camp.php b/app/Camp.php new file mode 100644 index 0000000..baed705 --- /dev/null +++ b/app/Camp.php @@ -0,0 +1,15 @@ +camp = $campRepository; + } + + /** + * Save camp + * + * @param Request $request + * @return $this|\Illuminate\Http\RedirectResponse + */ + public function save(Request $request) + { + + $messages = [ + 'region.required' => 'ග්‍රාම නිළධාරි වසම ඇතුලත් කිරීම අනිවාර්යයි', + 'location.required' => 'කදවුරු පිහිටි ස්ථානය ඇතුලත් කිරීම අනිවාර්යයි', + 'g-recaptcha-response.required' => 'ඔබව තහවුරු කිරීම අනිවාර්යයි' + ]; + + $validator = Validator::make($request->all(), [ + 'region' => 'required|max:100', + 'location' => 'required|max:100' + ], $messages); + + if ($validator->fails()) { + return redirect('/camps/add') + ->with('isSuccess', false) + ->with('errors', $validator->errors()->all()) + ->withInput(); + } else { + $response = $this->camp->addCamp($request->all()); + if ($response) { + return redirect('/camps') + ->with('isSuccess', true) + ->with('message', 'සාර්ථකව ඇතුලත්කරන ලදී.'); + } else { + return redirect('/camps/add') + ->with('isSuccess', false) + ->with('errors', ['ඇතුලත්කිරීම දෝෂ සහිතය.']) + ->withInput(); + } + } + } + + /** + * List all camps + * + * @return $this + */ + public function index() + { + $camps = $this->camp->getCamps(); + + return view('/frontend/camps/index')->with( + ['camps' => ($camps) ? $camps : array()] + ); + } + + /** + * Add camp + * + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + */ + public function add() + { + return view('/frontend/camps/add'); + } + + /** + * Show camp + * + * @param $id + * @return mixed + */ + public function show($id) + { + $camp = $this->camp->findCamp($id); + + if ($camp) { + return Response::json([ + 'isSuccess' => true, + 'donation' => $camp, + ]); + } else { + return Response::json([ + 'isSuccess' => false + ]); + } + } +} diff --git a/app/Repositories/CampRepository.php b/app/Repositories/CampRepository.php new file mode 100644 index 0000000..1847023 --- /dev/null +++ b/app/Repositories/CampRepository.php @@ -0,0 +1,63 @@ +getMessage()); + echo $e->getMessage(); + return false; + } + } + + /** + * Get all camps + * + * @param $limit + * @return mixed + */ + public function getCamps($limit = null) + { + try { + if ($limit) { + return Camp::orderBy('id', 'desc')->take($limit)->get(); + } + return Camp::orderBy('id', 'desc')->paginate(10); + } catch (\Exception $e) { + Log::error($e->getMessage()); + return false; + } + } + + /** + * Find camp + * + * @param $id + * @return mixed + */ + public function findCamp($id) + { + try { + return Camp::find($id); + } catch (\Exception $e) { + Log::error($e->getMessage()); + return false; + } + } +} \ No newline at end of file diff --git a/app/Repositories/Contracts/CampInterface.php b/app/Repositories/Contracts/CampInterface.php new file mode 100644 index 0000000..402fe55 --- /dev/null +++ b/app/Repositories/Contracts/CampInterface.php @@ -0,0 +1,29 @@ +increments('id'); + $table->string('region'); + $table->string('name')->nullable(); + $table->string('telephone')->nullable(); + $table->string('email')->nullable(); + + $table->integer('families')->nullable(); + $table->integer('men')->nullable(); + $table->integer('women')->nullable(); + $table->integer('children')->nullable(); + $table->integer('babies')->nullable(); + $table->integer('pregnents')->nullable(); + $table->integer('heart_patients')->nullable(); + $table->integer('blood_pressure_patients')->nullable(); + $table->integer('special_needs')->nullable(); + $table->integer('other_patients')->nullable(); + $table->integer('elders')->nullable(); + + $table->string('location'); + $table->integer('count')->nullable(); + $table->string('geograghy')->nullable(); + $table->string('route')->nullable(); + $table->string('pre_max_water_level')->nullable(); + $table->string('pre_settle_time')->nullable(); + + $table->string('transport_categories')->nullable(); + $table->string('transport_suppliers')->nullable(); + $table->string('boats_usable_locations')->nullable(); + $table->string('current_wires_locations')->nullable(); + $table->string('tree_cutter_suppliers')->nullable(); + + $table->integer('water_motors')->nullable(); + $table->integer('water_tanks')->nullable(); + $table->integer('lifesaving_jackets')->nullable(); + $table->integer('sanitary')->nullable(); + $table->integer('generators')->nullable(); + $table->integer('torches')->nullable(); + $table->integer('mosquito_nets_pillows')->nullable(); + $table->integer('cooking_instruments')->nullable(); + + $table->integer('deaths')->nullable(); + $table->integer('casualties')->nullable(); + $table->integer('full_damage_houses')->nullable(); + $table->integer('half_damage_houses')->nullable(); + $table->integer('full_damage_business')->nullable(); + $table->integer('half_damage_business')->nullable(); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('camps'); + } +} diff --git a/public/css/step-form.css b/public/css/step-form.css new file mode 100644 index 0000000..cb59bd6 --- /dev/null +++ b/public/css/step-form.css @@ -0,0 +1,42 @@ +body { + margin-top:40px; +} +.stepwizard-step p { + margin-top: 10px; +} +.stepwizard-row { + display: table-row; +} +.stepwizard { + display: table; + width: 50%; + position: relative; +} +.stepwizard-step button[disabled] { + opacity: 1 !important; + filter: alpha(opacity=100) !important; +} +.stepwizard-row:before { + top: 14px; + bottom: 0; + position: absolute; + content: " "; + width: 100%; + height: 1px; + background-color: #ccc; + z-order: 0; +} +.stepwizard-step { + display: table-cell; + text-align: center; + position: relative; +} +.btn-circle { + width: 30px; + height: 30px; + text-align: center; + padding: 6px 0; + font-size: 12px; + line-height: 1.428571429; + border-radius: 15px; +} \ No newline at end of file diff --git a/public/js/step-form.js b/public/js/step-form.js new file mode 100644 index 0000000..a88458c --- /dev/null +++ b/public/js/step-form.js @@ -0,0 +1,42 @@ +$(document).ready(function () { + var navListItems = $('div.setup-panel div a'), + allWells = $('.setup-content'), + allNextBtn = $('.nextBtn'); + + allWells.hide(); + + navListItems.click(function (e) { + e.preventDefault(); + var $target = $($(this).attr('href')), + $item = $(this); + + if (!$item.hasClass('disabled')) { + navListItems.removeClass('btn-primary').addClass('btn-default'); + $item.addClass('btn-primary'); + allWells.hide(); + $target.show(); + $target.find('input:eq(0)').focus(); + } + }); + + allNextBtn.click(function(){ + var curStep = $(this).closest(".setup-content"), + curStepBtn = curStep.attr("id"), + nextStepWizard = $('div.setup-panel div a[href="#' + curStepBtn + '"]').parent().next().children("a"), + curInputs = curStep.find("input[type='text'],input[type='url']"), + isValid = true; + + $(".form-group").removeClass("has-error"); + for(var i=0; i +@endsection + +@section('content') +
+
+ @if (session('errors')) +
+
    + @foreach (session('errors') as $error) +
  • {{ $error }}
  • + @endforeach +
+
+ @endif +

කදවුරු එකතු කරන්න

+ +
+
+
+ 1 +

ග්‍රාම නිළධාරි තොරතුරු

+
+
+ 2 +

මානව තොරතුරු

+
+
+ 3 +

කදවුරේ තොරතුරු

+
+
+ 4 +

ප්‍රවාහන තොරතුරු

+
+
+ 5 +

වෙනත් භාණ්‍ඩ

+
+
+ 6 +

අපදා තක්සේරුව

+
+
+
+ + +
+ +
+ {{ csrf_field() }} + +
+ ග්‍රාම නිළධාරි තොරතුරු +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+
+
+
+ මානව තොරතුරු +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+
+
+
+ කදවුරේ තොරතුරු +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+
+
+
+ ප්‍රවාහන සහ යන්ත්‍ර සැපයුම් කරුවන් +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+
+
+
+ වෙනත් භාණ්‍ඩ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+
+
+
+ +
+
+
+
+ අපදා තක්සේරුව +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ + + + + +
+
+ +
+
+
+ +
+
+
+ +
+@endsection + +@section('js-content') + +@endsection \ No newline at end of file diff --git a/resources/views/frontend/camps/index.blade.php b/resources/views/frontend/camps/index.blade.php new file mode 100644 index 0000000..21f211a --- /dev/null +++ b/resources/views/frontend/camps/index.blade.php @@ -0,0 +1,97 @@ +@extends('layouts.master') + +@section('content') +
+
+
+ @if (session('message')) +
+ {{ session('message') }} +
+ @endif +

+ +

+ + + + + + + + + + + + + + + @foreach($camps as $camp) + + + + + + + + + + + + + @endforeach + +
#ග්‍රාම නිළධාරි වසමග්‍රාම නිළධාරිගේ නමකදවුරු පිහිටි ස්ථානයපවුල් ගණනග්‍රාම නිළධාරිගේ දුරකථනඇතුල්කලේ
{{ $camp->id }}{{ $camp->region }}{{ str_limit($camp->name, 150) }}{{ str_limit($camp->location, 150) }}{{ $camp->families }}{{ $camp->telephone }}{{ $camp->created_at }} + + + + + +
+
+
+ +
+
+ @if($camps && $camps->links()) + {{ $camps->links() }} + @endif +
+
+ +
+ + +@endsection \ No newline at end of file diff --git a/resources/views/layouts/master.blade.php b/resources/views/layouts/master.blade.php index 38ea805..50662b9 100644 --- a/resources/views/layouts/master.blade.php +++ b/resources/views/layouts/master.blade.php @@ -18,6 +18,7 @@ + @yield('head-content') @@ -46,6 +47,7 @@
  • මුල් පිටුව
  • ආධාර
  • අවශ්‍යතාවයන්
  • +
  • කදවුරු
  • අත්‍යවශ්‍ය දුරකථන අංක
  • #WeatherSL Twitter Feed
  • @@ -80,10 +82,10 @@ - +@yield('js-content') diff --git a/routes/web.php b/routes/web.php index 69b2833..a746aab 100644 --- a/routes/web.php +++ b/routes/web.php @@ -29,3 +29,8 @@ Route::get('/entry/{type}/{id}', 'EntryController@view'); Route::post('/search-donations-needs', 'HomeController@searchDonationsOrNeeds'); + +Route::get('/camps', 'CampController@index'); +Route::get('/camps/add', 'CampController@add'); +Route::post('/camps/add', 'CampController@save'); +Route::get('/camps/show/{id}', 'CampController@show'); \ No newline at end of file