From 505599251eb29d17d572910ee3a8bb48d5b1f712 Mon Sep 17 00:00:00 2001 From: JapSeyz Date: Mon, 28 Nov 2016 13:43:28 +0100 Subject: [PATCH] Active / inactive sponsors --- .../Controllers/EventSponsorController.php | 2 ++ app/Models/Sponsor.php | 6 +++- ...16_11_28_133604_add_active_to_sponsors.php | 31 +++++++++++++++++++ .../Modals/ManageSponsor.blade.php | 10 ++++++ .../views/ManageEvent/Sponsors.blade.php | 9 ++---- 5 files changed, 51 insertions(+), 7 deletions(-) create mode 100644 database/migrations/2016_11_28_133604_add_active_to_sponsors.php diff --git a/app/Http/Controllers/EventSponsorController.php b/app/Http/Controllers/EventSponsorController.php index 04a92479..2c752ad2 100644 --- a/app/Http/Controllers/EventSponsorController.php +++ b/app/Http/Controllers/EventSponsorController.php @@ -143,6 +143,7 @@ class EventSponsorController extends MyBaseController 'name' => 'required|max:250', 'sponsor_logo' => 'image', 'on_ticket' => 'boolean', + 'is_active' => 'boolean', ]; $validator = Validator::make($request->all(), $rules); @@ -173,6 +174,7 @@ class EventSponsorController extends MyBaseController } $sponsor->on_ticket = $request->has('on_ticket'); + $sponsor->is_active = $request->has('is_active'); $sponsor->name = $request->get('name'); $sponsor->save(); diff --git a/app/Models/Sponsor.php b/app/Models/Sponsor.php index be32d3ab..d6bd6160 100644 --- a/app/Models/Sponsor.php +++ b/app/Models/Sponsor.php @@ -6,7 +6,6 @@ namespace App\Models; */ class Sponsor extends \Illuminate\Database\Eloquent\Model { - /** * Get the full logo path of the sponsor. * @@ -20,4 +19,9 @@ class Sponsor extends \Illuminate\Database\Eloquent\Model return config('attendize.fallback_organiser_logo_url'); } + + public function scopeActive($query) + { + return $query->where('is_active', 1); + } } \ No newline at end of file diff --git a/database/migrations/2016_11_28_133604_add_active_to_sponsors.php b/database/migrations/2016_11_28_133604_add_active_to_sponsors.php new file mode 100644 index 00000000..8d2c7166 --- /dev/null +++ b/database/migrations/2016_11_28_133604_add_active_to_sponsors.php @@ -0,0 +1,31 @@ +boolean('is_active')->default(0); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('sponsors', function($table){ + $table->dropColumn('is_active'); + }); + } +} diff --git a/resources/views/ManageEvent/Modals/ManageSponsor.blade.php b/resources/views/ManageEvent/Modals/ManageSponsor.blade.php index bc5ddb5f..f7a70412 100644 --- a/resources/views/ManageEvent/Modals/ManageSponsor.blade.php +++ b/resources/views/ManageEvent/Modals/ManageSponsor.blade.php @@ -38,6 +38,16 @@ +
+
+
+
+ {!! Form::label('is_active', 'Active?', array('class'=>'control-label ')) !!} + {!! Form::checkbox('is_active', 1, $sponsor->is_active) !!} +
+
+
+
diff --git a/resources/views/ManageEvent/Sponsors.blade.php b/resources/views/ManageEvent/Sponsors.blade.php index 5eaa1e08..a621bc45 100644 --- a/resources/views/ManageEvent/Sponsors.blade.php +++ b/resources/views/ManageEvent/Sponsors.blade.php @@ -41,11 +41,6 @@
- {{-- New Sponsor Form --}} - {{-- Edit Sponsor onClick --}} - {{-- Delete Sponsor --}} - - {{-- Show Sponsors --}}
@@ -53,7 +48,8 @@ Name - On Ticket + On Ticket + Active @@ -63,6 +59,7 @@ {{ $sponsor->name }} {{ $sponsor->on_ticket ? 'Yes' : 'No' }} + {{ $sponsor->is_active ? 'Yes' : 'No' }} {!! Form::open(array('url' => route('postDeleteSponsor', ['event_id' => $event->id, 'sponsor_id' => $sponsor->id]), 'class' => 'ajax text-right')) !!} {!! Form::submit('Delete Sponsor', ['class'=>"btn btn-danger"]) !!}