Award Checks Update (#1376)
Add active/passive check for awards and update the handler to pass only active ones to the process when needed.
This commit is contained in:
parent
023313c681
commit
09453becf8
@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Contracts\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class UpdateAwardsAddActive extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('awards', function (Blueprint $table) {
|
||||||
|
$table->boolean('active')->default(true)->nullable()->after('ref_model_params');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -60,7 +60,7 @@ class AwardHandler extends Listener
|
|||||||
*/
|
*/
|
||||||
public function checkForAwards($user)
|
public function checkForAwards($user)
|
||||||
{
|
{
|
||||||
$awards = Award::all();
|
$awards = Award::where('active', 1)->get();
|
||||||
foreach ($awards as $award) {
|
foreach ($awards as $award) {
|
||||||
$klass = $award->getReference($award, $user);
|
$klass = $award->getReference($award, $user);
|
||||||
if ($klass) {
|
if ($klass) {
|
||||||
|
@ -21,6 +21,7 @@ class Award extends Model
|
|||||||
'image_url',
|
'image_url',
|
||||||
'ref_model',
|
'ref_model',
|
||||||
'ref_model_params',
|
'ref_model_params',
|
||||||
|
'active',
|
||||||
];
|
];
|
||||||
|
|
||||||
public static $rules = [
|
public static $rules = [
|
||||||
@ -29,6 +30,7 @@ class Award extends Model
|
|||||||
'image_url' => 'nullable',
|
'image_url' => 'nullable',
|
||||||
'ref_model' => 'required',
|
'ref_model' => 'required',
|
||||||
'ref_model_params' => 'nullable',
|
'ref_model_params' => 'nullable',
|
||||||
|
'active' => 'nullable',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
@extends('admin.app')
|
@extends('admin.app')
|
||||||
@section('title', "Edit \"$award->title\" Award")
|
@section('title', "Edit \"$award->name\" Award")
|
||||||
@section('content')
|
@section('content')
|
||||||
<div class="card border-blue-bottom">
|
<div class="card border-blue-bottom">
|
||||||
<div class="content">
|
<div class="content">
|
||||||
|
@ -18,17 +18,13 @@
|
|||||||
<p class="text-danger">{{ $errors->first('name') }}</p>
|
<p class="text-danger">{{ $errors->first('name') }}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="form-group col-sm-6">
|
<div class="form-group col-sm-6">
|
||||||
{!! Form::label('image', 'Image:') !!}
|
{!! Form::label('image', 'Image:') !!}
|
||||||
<div class="callout callout-info">
|
<div class="callout callout-info">
|
||||||
<i class="icon fa fa-info"> </i>
|
<i class="icon fa fa-info"> </i>
|
||||||
This is the image of the award. Be creative!
|
This is the image of the award. Be creative!
|
||||||
</div>
|
</div>
|
||||||
{!! Form::text('image_url', null, [
|
{!! Form::text('image_url', null, ['class' => 'form-control', 'placeholder' => 'Enter the url of the image location']) !!}
|
||||||
'class' => 'form-control',
|
|
||||||
'placeholder' => 'Enter the url of the image location'
|
|
||||||
]) !!}
|
|
||||||
<p class="text-danger">{{ $errors->first('image_url') }}</p>
|
<p class="text-danger">{{ $errors->first('image_url') }}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -47,29 +43,31 @@
|
|||||||
<div class="form-group col-sm-6">
|
<div class="form-group col-sm-6">
|
||||||
<div>
|
<div>
|
||||||
{{ Form::label('ref_model', 'Award Class:') }}
|
{{ Form::label('ref_model', 'Award Class:') }}
|
||||||
{{ Form::select('ref_model', $award_classes, null , [
|
{{ Form::select('ref_model', $award_classes, null, ['class' => 'form-control select2', 'id' => 'award_class_select']) }}
|
||||||
'class' => 'form-control select2',
|
|
||||||
'id' => 'award_class_select',
|
|
||||||
]) }}
|
|
||||||
<p class="text-danger">{{ $errors->first('ref_model') }}</p>
|
<p class="text-danger">{{ $errors->first('ref_model') }}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
{{ Form::label('ref_model_params', 'Award Class parameters') }}
|
{{ Form::label('ref_model_params', 'Award Class parameters') }}
|
||||||
{{ Form::text('ref_model_params', null, ['class' => 'form-control']) }}
|
{{ Form::text('ref_model_params', null, ['class' => 'form-control']) }}
|
||||||
<p class="text-danger">{{ $errors->first('ref_model_params') }}</p>
|
<p class="text-danger">{{ $errors->first('ref_model_params') }}</p>
|
||||||
|
<p id="ref_model_param_description"></p>
|
||||||
<p id="ref_model_param_description">
|
|
||||||
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<!-- Submit Field -->
|
{{-- Active/Deactive Checkbox --}}
|
||||||
<div class="form-group col-sm-12">
|
<div class="form-group col-sm-6 text-left">
|
||||||
|
<div class="checkbox">
|
||||||
|
<label class="checkbox-inline">
|
||||||
|
{{ Form::label('active', 'Active: ') }}
|
||||||
|
{{ Form::hidden('active', false) }}
|
||||||
|
{{ Form::checkbox('active') }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{-- Form Actions --}}
|
||||||
|
<div class="form-group col-sm-6">
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
{!! Form::button('Save', ['type' => 'submit', 'class' => 'btn btn-success']) !!}
|
{!! Form::button('Save', ['type' => 'submit', 'class' => 'btn btn-success']) !!}
|
||||||
<a href="{!! route('admin.awards.index') !!}" class="btn btn-warn">Cancel</a>
|
<a href="{!! route('admin.awards.index') !!}" class="btn btn-warn">Cancel</a>
|
||||||
|
@ -1,40 +1,47 @@
|
|||||||
<table class="table table-hover table-responsive" id="awards-table">
|
<table class="table table-hover table-responsive" id="awards-table">
|
||||||
<thead>
|
<thead>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th>Description</th>
|
<th>Description</th>
|
||||||
<th>Image</th>
|
<th>Image</th>
|
||||||
<th class="text-right">Action</th>
|
<th class="text-center">Active</th>
|
||||||
|
<th class="text-right">Action</th>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach($awards as $award)
|
@foreach($awards->sortby('name', SORT_NATURAL) as $award)
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<a href="{{ route('admin.awards.edit', [$award->id]) }}">
|
<a href="{{ route('admin.awards.edit', [$award->id]) }}">{{ $award->name }}</a>
|
||||||
{{ $award->name }}</a>
|
</td>
|
||||||
</td>
|
<td>
|
||||||
<td>{{ $award->description }}</td>
|
{{ $award->description }}
|
||||||
<td>
|
</td>
|
||||||
|
<td>
|
||||||
@if($award->image_url)
|
@if($award->image_url)
|
||||||
<img src="{{ $award->image_url }}" name="{{ $award->name }}" alt="No Image Available" style="height: 100px"/>
|
<img src="{{ $award->image_url }}" name="{{ $award->name }}" alt="No Image Available" style="height: 100px"/>
|
||||||
@else
|
@else
|
||||||
-
|
-
|
||||||
@endif
|
@endif
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-center">
|
||||||
{{ Form::open(['route' => ['admin.awards.destroy', $award->id], 'method' => 'delete']) }}
|
@if($award->active)
|
||||||
<a href="{{ route('admin.awards.edit', [$award->id]) }}" class='btn btn-sm btn-success btn-icon'>
|
<i class="fas fa-check-circle fa-2x text-success"></i>
|
||||||
<i class="fas fa-pencil-alt"></i></a>
|
@else
|
||||||
|
<i class="fas fa-times-circle fa-2x text-danger"></i>
|
||||||
{{ Form::button('<i class="fa fa-times"></i>', [
|
@endif
|
||||||
'type' => 'submit',
|
</td>
|
||||||
'class' => 'btn btn-sm btn-danger btn-icon',
|
<td class="text-right">
|
||||||
'onclick' => "return confirm('Are you sure you want to delete this award?')"
|
{{ Form::open(['route' => ['admin.awards.destroy', $award->id], 'method' => 'delete']) }}
|
||||||
]) }}
|
<a href="{{ route('admin.awards.edit', [$award->id]) }}" class='btn btn-sm btn-success btn-icon'>
|
||||||
|
<i class="fas fa-pencil-alt"></i>
|
||||||
{{ Form::close() }}
|
</a>
|
||||||
</td>
|
{{ Form::button('<i class="fa fa-times"></i>', [
|
||||||
</tr>
|
'type' => 'submit',
|
||||||
@endforeach
|
'class' => 'btn btn-sm btn-danger btn-icon',
|
||||||
|
'onclick' => "return confirm('Are you sure you want to delete this award?')"
|
||||||
|
]) }}
|
||||||
|
{{ Form::close() }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
Loading…
Reference in New Issue
Block a user