Filter out cancelled PIREPs

This commit is contained in:
Nabeel Shahzad 2018-01-03 09:54:32 -06:00
parent 8744a8b17b
commit 162057f940
2 changed files with 17 additions and 1 deletions

View File

@ -104,6 +104,16 @@ class CreateSettingsTable extends Migration
'type' => 'int',
'description' => 'The time in minutes to check for a duplicate PIREP',
],
[
'id' => $this->formatSettingId('pireps.hide_cancelled_pireps'),
'order' => $this->getNextOrderNumber('pireps'),
'name' => 'Hide Cancelled PIREPs',
'group' => 'pireps',
'value' => true,
'default' => true,
'type' => 'boolean',
'description' => 'Hide any cancelled PIREPs in the front-end',
],
[
'id' => $this->formatSettingId('pilots.id_length'),
'order' => $this->getNextOrderNumber('pilots'),

View File

@ -4,6 +4,7 @@ namespace App\Http\Controllers\Frontend;
use App\Facades\Utils;
use App\Models\Enums\PirepSource;
use App\Models\Enums\PirepState;
use App\Repositories\Criteria\WhereCriteria;
use App\Services\GeoService;
use App\Services\PIREPService;
@ -54,7 +55,12 @@ class PirepController extends Controller
{
$user = Auth::user();
$where = ['user_id' => $user->id];
$where = [['user_id', $user->id]];
if(setting('pireps.hide_cancelled_pireps')) {
$where[] = ['state', '<>', PirepState::CANCELLED];
}
$this->pirepRepo->pushCriteria(new WhereCriteria($request, $where));
$pireps = $this->pirepRepo->orderBy('created_at', 'desc')->paginate();