diff --git a/app/Database/migrations/2022_01_10_131604_update_awards_add_active.php b/app/Database/migrations/2022_01_10_131604_update_awards_add_active.php new file mode 100644 index 00000000..8d8baf9f --- /dev/null +++ b/app/Database/migrations/2022_01_10_131604_update_awards_add_active.php @@ -0,0 +1,15 @@ +boolean('active')->default(true)->nullable()->after('ref_model_params'); + }); + } +} diff --git a/app/Listeners/AwardHandler.php b/app/Listeners/AwardHandler.php index 52463acf..0e74419e 100644 --- a/app/Listeners/AwardHandler.php +++ b/app/Listeners/AwardHandler.php @@ -60,7 +60,7 @@ class AwardHandler extends Listener */ public function checkForAwards($user) { - $awards = Award::all(); + $awards = Award::where('active', 1)->get(); foreach ($awards as $award) { $klass = $award->getReference($award, $user); if ($klass) { diff --git a/app/Models/Award.php b/app/Models/Award.php index 632ba861..e501fb98 100755 --- a/app/Models/Award.php +++ b/app/Models/Award.php @@ -21,6 +21,7 @@ class Award extends Model 'image_url', 'ref_model', 'ref_model_params', + 'active', ]; public static $rules = [ @@ -29,6 +30,7 @@ class Award extends Model 'image_url' => 'nullable', 'ref_model' => 'required', 'ref_model_params' => 'nullable', + 'active' => 'nullable', ]; /** diff --git a/resources/views/admin/awards/edit.blade.php b/resources/views/admin/awards/edit.blade.php index ba39366b..c27eb54a 100755 --- a/resources/views/admin/awards/edit.blade.php +++ b/resources/views/admin/awards/edit.blade.php @@ -1,5 +1,5 @@ @extends('admin.app') -@section('title', "Edit \"$award->title\" Award") +@section('title', "Edit \"$award->name\" Award") @section('content')
diff --git a/resources/views/admin/awards/fields.blade.php b/resources/views/admin/awards/fields.blade.php index 3a0edc99..36814730 100755 --- a/resources/views/admin/awards/fields.blade.php +++ b/resources/views/admin/awards/fields.blade.php @@ -18,17 +18,13 @@

{{ $errors->first('name') }}

-
{!! Form::label('image', 'Image:') !!}
   This is the image of the award. Be creative!
- {!! Form::text('image_url', null, [ - 'class' => 'form-control', - 'placeholder' => 'Enter the url of the image location' - ]) !!} + {!! Form::text('image_url', null, ['class' => 'form-control', 'placeholder' => 'Enter the url of the image location']) !!}

{{ $errors->first('image_url') }}

@@ -47,29 +43,31 @@
{{ Form::label('ref_model', 'Award Class:') }} - {{ Form::select('ref_model', $award_classes, null , [ - 'class' => 'form-control select2', - 'id' => 'award_class_select', - ]) }} + {{ Form::select('ref_model', $award_classes, null, ['class' => 'form-control select2', 'id' => 'award_class_select']) }}

{{ $errors->first('ref_model') }}

-
{{ Form::label('ref_model_params', 'Award Class parameters') }} {{ Form::text('ref_model_params', null, ['class' => 'form-control']) }}

{{ $errors->first('ref_model_params') }}

- -

- -

+

-
- -
+ {{-- Active/Deactive Checkbox --}} +
+
+ +
+
+ {{-- Form Actions --}} +
{!! Form::button('Save', ['type' => 'submit', 'class' => 'btn btn-success']) !!} Cancel diff --git a/resources/views/admin/awards/table.blade.php b/resources/views/admin/awards/table.blade.php index 69d7c416..9e33a2d9 100755 --- a/resources/views/admin/awards/table.blade.php +++ b/resources/views/admin/awards/table.blade.php @@ -1,40 +1,47 @@ - - - - + + + + + - @foreach($awards as $award) - - - - - - - @endforeach + @foreach($awards->sortby('name', SORT_NATURAL) as $award) + + + + + + + + @endforeach -
NameDescriptionImageActionNameDescriptionImageActiveAction
- - {{ $award->name }} - {{ $award->description }} - - @if($award->image_url) - No Image Available - @else - - - @endif - - {{ 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() }} -
+ {{ $award->name }} + + {{ $award->description }} + + @if($award->image_url) + No Image Available + @else + - + @endif + + @if($award->active) + + @else + + @endif + + {{ 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() }} +
+ \ No newline at end of file