hide all cancelled pireps #180

This commit is contained in:
Nabeel Shahzad 2018-02-10 13:25:40 -06:00
parent 3ded06390c
commit 8acb9291fe
3 changed files with 6 additions and 7 deletions

View File

@ -136,13 +136,13 @@ class CreateSettingsTable extends Migration
'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',
'group' => 'pireps',
'value' => true,
'type' => 'boolean',
'description' => 'Hide any cancelled PIREPs in the front-end',
]);
]);*/
$this->addSetting('pireps.restrict_aircraft_to_rank', [
'name' => 'Restrict Aircraft to Ranks',

View File

@ -94,10 +94,7 @@ class PirepController extends Controller
$user = Auth::user();
$where = [['user_id', $user->id]];
if(setting('pireps.hide_cancelled_pireps')) {
$where[] = ['state', '<>', PirepState::CANCELLED];
}
$where[] = ['state', '<>', PirepState::CANCELLED];
$this->pirepRepo->pushCriteria(new WhereCriteria($request, $where));
$pireps = $this->pirepRepo->orderBy('created_at', 'desc')->paginate();

View File

@ -2,6 +2,7 @@
namespace App\Models;
use App\Models\Enums\PirepState;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Laratrust\Traits\LaratrustUserTrait;
@ -159,7 +160,8 @@ class User extends Authenticatable
public function pireps()
{
return $this->hasMany(Pirep::class, 'user_id');
return $this->hasMany(Pirep::class, 'user_id')
->where('state', '!=', PirepState::CANCELLED);
}
public function rank()