hide all cancelled pireps #180
This commit is contained in:
@@ -136,13 +136,13 @@ class CreateSettingsTable extends Migration
|
|||||||
'description' => 'The time in minutes to check for a duplicate PIREP',
|
'description' => 'The time in minutes to check for a duplicate PIREP',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->addSetting('pireps.hide_cancelled_pireps', [
|
/*$this->addSetting('pireps.hide_cancelled_pireps', [
|
||||||
'name' => 'Hide Cancelled PIREPs',
|
'name' => 'Hide Cancelled PIREPs',
|
||||||
'group' => 'pireps',
|
'group' => 'pireps',
|
||||||
'value' => true,
|
'value' => true,
|
||||||
'type' => 'boolean',
|
'type' => 'boolean',
|
||||||
'description' => 'Hide any cancelled PIREPs in the front-end',
|
'description' => 'Hide any cancelled PIREPs in the front-end',
|
||||||
]);
|
]);*/
|
||||||
|
|
||||||
$this->addSetting('pireps.restrict_aircraft_to_rank', [
|
$this->addSetting('pireps.restrict_aircraft_to_rank', [
|
||||||
'name' => 'Restrict Aircraft to Ranks',
|
'name' => 'Restrict Aircraft to Ranks',
|
||||||
|
|||||||
@@ -94,10 +94,7 @@ class PirepController extends Controller
|
|||||||
$user = Auth::user();
|
$user = Auth::user();
|
||||||
|
|
||||||
$where = [['user_id', $user->id]];
|
$where = [['user_id', $user->id]];
|
||||||
|
$where[] = ['state', '<>', PirepState::CANCELLED];
|
||||||
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();
|
||||||
|
|||||||
+3
-1
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use App\Models\Enums\PirepState;
|
||||||
use Illuminate\Notifications\Notifiable;
|
use Illuminate\Notifications\Notifiable;
|
||||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
use Laratrust\Traits\LaratrustUserTrait;
|
use Laratrust\Traits\LaratrustUserTrait;
|
||||||
@@ -159,7 +160,8 @@ class User extends Authenticatable
|
|||||||
|
|
||||||
public function pireps()
|
public function pireps()
|
||||||
{
|
{
|
||||||
return $this->hasMany(Pirep::class, 'user_id');
|
return $this->hasMany(Pirep::class, 'user_id')
|
||||||
|
->where('state', '!=', PirepState::CANCELLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rank()
|
public function rank()
|
||||||
|
|||||||
Reference in New Issue
Block a user