Filter out cancelled PIREPs
This commit is contained in:
@@ -104,6 +104,16 @@ class CreateSettingsTable extends Migration
|
|||||||
'type' => 'int',
|
'type' => 'int',
|
||||||
'description' => 'The time in minutes to check for a duplicate PIREP',
|
'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'),
|
'id' => $this->formatSettingId('pilots.id_length'),
|
||||||
'order' => $this->getNextOrderNumber('pilots'),
|
'order' => $this->getNextOrderNumber('pilots'),
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Frontend;
|
|||||||
|
|
||||||
use App\Facades\Utils;
|
use App\Facades\Utils;
|
||||||
use App\Models\Enums\PirepSource;
|
use App\Models\Enums\PirepSource;
|
||||||
|
use App\Models\Enums\PirepState;
|
||||||
use App\Repositories\Criteria\WhereCriteria;
|
use App\Repositories\Criteria\WhereCriteria;
|
||||||
use App\Services\GeoService;
|
use App\Services\GeoService;
|
||||||
use App\Services\PIREPService;
|
use App\Services\PIREPService;
|
||||||
@@ -54,7 +55,12 @@ class PirepController extends Controller
|
|||||||
{
|
{
|
||||||
$user = Auth::user();
|
$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));
|
$this->pirepRepo->pushCriteria(new WhereCriteria($request, $where));
|
||||||
$pireps = $this->pirepRepo->orderBy('created_at', 'desc')->paginate();
|
$pireps = $this->pirepRepo->orderBy('created_at', 'desc')->paginate();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user