Merge branch 'dev' of github.com:nabeelio/phpvms into dev

This commit is contained in:
Nabeel Shahzad
2018-04-23 10:25:11 -05:00
3 changed files with 28 additions and 7 deletions

View File

@@ -190,9 +190,7 @@ class PirepController extends Controller
$this->pirepRepo->pushCriteria($criterea);
$pireps = $this->pirepRepo
->findWhere(['status', '!=', PirepState::CANCELLED])
->findWhere(['status', '!=', PirepState::DRAFT])
->orderBy('created_at', 'desc')
->whereNotInOrder('status', [PirepState::CANCELLED, PirepState::DRAFT], 'created_at', 'desc')
->paginate();
return view('admin.pireps.index', [

View File

@@ -76,4 +76,29 @@ abstract class Repository extends \Prettus\Repository\Eloquent\BaseRepository
return $q;
});
}
/**
* Find records where values don't match a list but sort the rest
* @param string $col
* @param array $values
* @param string $sort_by
* @param string $order_by
* @return $this
*/
public function whereNotInOrder($col, $values, $sort_by, $order_by = 'asc')
{
return $this->scopeQuery(function ($query) use ($col, $values, $sort_by, $order_by) {
$q = $query->whereNotIn($col, $values);
# See if there are multi-column sorts
if (\is_array($sort_by)) {
foreach ($sort_by as $key => $sort) {
$q = $q->orderBy($key, $sort);
}
} else {
$q = $q->orderBy($sort_by, $order_by);
}
return $q;
});
}
}

View File

@@ -163,7 +163,7 @@ class FlightTest extends TestCase
$this->user = factory(App\Models\User::class)->create();
// Set it to Monday or Tuesday, depending on what today is
if (date('N') === 1) { // today is a monday
if (date('N') === '1') { // today is a monday
$days = Days::getDaysMask([Days::TUESDAY]);
} else {
$days = Days::getDaysMask([Days::MONDAY]);
@@ -172,8 +172,6 @@ class FlightTest extends TestCase
factory(App\Models\Flight::class, 5)->create();
$flight = factory(App\Models\Flight::class)->create([
'days' => $days,
#'start_date' => Carbon\Carbon::now('UTC')->subDay(1),
#'end_date' => Carbon\Carbon::now('UTC')->addDays(1),
]);
// Run the event that will enable/disable flights
@@ -221,7 +219,7 @@ class FlightTest extends TestCase
$this->user = factory(App\Models\User::class)->create();
// Set it to Monday or Tuesday, depending on what today is
if (date('N') === 1) { // today is a monday
if (date('N') === '1') { // today is a monday
$days = Days::getDaysMask([Days::TUESDAY]);
} else {
$days = Days::getDaysMask([Days::MONDAY]);