simple user search and pagination
This commit is contained in:
@@ -2,19 +2,15 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers\Admin;
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
use App\Models\Airline;
|
|
||||||
use App\Models\FlightFields;
|
use App\Models\FlightFields;
|
||||||
use App\Models\Airport;
|
|
||||||
use App\Http\Requests\CreateFlightRequest;
|
use App\Http\Requests\CreateFlightRequest;
|
||||||
use App\Http\Requests\UpdateFlightRequest;
|
use App\Http\Requests\UpdateFlightRequest;
|
||||||
use App\Repositories\AirlineRepository;
|
use App\Repositories\AirlineRepository;
|
||||||
use App\Repositories\AirportRepository;
|
use App\Repositories\AirportRepository;
|
||||||
use App\Repositories\FlightRepository;
|
use App\Repositories\FlightRepository;
|
||||||
use App\Repositories\SubfleetRepository;
|
use App\Repositories\SubfleetRepository;
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Flash;
|
use Flash;
|
||||||
use Prettus\Repository\Criteria\RequestCriteria;
|
|
||||||
use Response;
|
use Response;
|
||||||
|
|
||||||
class FlightController extends BaseController
|
class FlightController extends BaseController
|
||||||
|
|||||||
@@ -8,10 +8,8 @@ use App\Repositories\UserRepository;
|
|||||||
use DB;
|
use DB;
|
||||||
use Hash;
|
use Hash;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
|
||||||
use Flash;
|
use Flash;
|
||||||
use Jackiedo\Timezonelist\Facades\Timezonelist;
|
use Jackiedo\Timezonelist\Facades\Timezonelist;
|
||||||
use Prettus\Repository\Criteria\RequestCriteria;
|
|
||||||
use Response;
|
use Response;
|
||||||
|
|
||||||
use App\Models\Airport;
|
use App\Models\Airport;
|
||||||
@@ -38,10 +36,11 @@ class UserController extends BaseController
|
|||||||
|
|
||||||
public function index(Request $request)
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
$this->userRepo->pushCriteria(new RequestCriteria($request));
|
$users = $this->userRepo->searchCriteria($request, false)->paginate();
|
||||||
|
/*$this->userRepo->pushCriteria(new RequestCriteria($request));
|
||||||
$users = $this->userRepo
|
$users = $this->userRepo
|
||||||
->orderBy('created_at', 'desc')
|
->orderBy('created_at', 'desc')
|
||||||
->paginate();
|
->paginate();*/
|
||||||
|
|
||||||
return view('admin.users.index', [
|
return view('admin.users.index', [
|
||||||
'users' => $users,
|
'users' => $users,
|
||||||
|
|||||||
@@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
namespace App\Repositories;
|
namespace App\Repositories;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Prettus\Repository\Contracts\CacheableInterface;
|
||||||
|
|
||||||
use App\Models\Flight;
|
use App\Models\Flight;
|
||||||
use App\Repositories\Criteria\WhereCriteria;
|
use App\Repositories\Criteria\WhereCriteria;
|
||||||
use App\Repositories\Traits\CacheableRepository;
|
use App\Repositories\Traits\CacheableRepository;
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Prettus\Repository\Contracts\CacheableInterface;
|
|
||||||
|
|
||||||
class FlightRepository extends BaseRepository implements CacheableInterface
|
class FlightRepository extends BaseRepository implements CacheableInterface
|
||||||
{
|
{
|
||||||
@@ -28,7 +28,7 @@ class FlightRepository extends BaseRepository implements CacheableInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the search criteria and return this with the stuff pushed
|
* Create the search criteria and return this with the stuff pushed
|
||||||
* @param FormRequest $request
|
* @param Request $request
|
||||||
* @param bool $only_active
|
* @param bool $only_active
|
||||||
* @return $this
|
* @return $this
|
||||||
* @throws \Prettus\Repository\Exceptions\RepositoryException
|
* @throws \Prettus\Repository\Exceptions\RepositoryException
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Repositories;
|
namespace App\Repositories;
|
||||||
|
|
||||||
use App\Models\Enums\PilotState;
|
use Illuminate\Http\Request;
|
||||||
use App\Models\User;
|
|
||||||
use App\Repositories\Traits\CacheableRepository;
|
|
||||||
use Prettus\Repository\Contracts\CacheableInterface;
|
use Prettus\Repository\Contracts\CacheableInterface;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Models\Enums\PilotState;
|
||||||
|
use App\Repositories\Criteria\WhereCriteria;
|
||||||
|
use App\Repositories\Traits\CacheableRepository;
|
||||||
|
|
||||||
class UserRepository extends BaseRepository implements CacheableInterface
|
class UserRepository extends BaseRepository implements CacheableInterface
|
||||||
{
|
{
|
||||||
use CacheableRepository;
|
use CacheableRepository;
|
||||||
@@ -36,4 +39,31 @@ class UserRepository extends BaseRepository implements CacheableInterface
|
|||||||
$users = $this->orderBy('created_at', 'desc')->findWhere($where)->count();
|
$users = $this->orderBy('created_at', 'desc')->findWhere($where)->count();
|
||||||
return $users;
|
return $users;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the search criteria and return this with the stuff pushed
|
||||||
|
* @param Request $request
|
||||||
|
* @param bool $only_active
|
||||||
|
* @return $this
|
||||||
|
* @throws \Prettus\Repository\Exceptions\RepositoryException
|
||||||
|
*/
|
||||||
|
public function searchCriteria(Request $request, bool $only_active = true)
|
||||||
|
{
|
||||||
|
$where = [];
|
||||||
|
|
||||||
|
if($only_active) {
|
||||||
|
$where['state'] = PilotState::ACTIVE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->filled('name')) {
|
||||||
|
$where['name'] = $request->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->filled('email')) {
|
||||||
|
$where['email'] = $request->email;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->pushCriteria(new WhereCriteria($request, $where));
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<th>Flight #</th>
|
<th>Flight #</th>
|
||||||
<th>Dep</th>
|
<th>Dep</th>
|
||||||
<th>Arr</th>
|
<th>Arr</th>
|
||||||
<th>Route</th>
|
{{--<th>Route</th>--}}
|
||||||
<th>Dpt Time</th>
|
<th>Dpt Time</th>
|
||||||
<th>Arr Time</th>
|
<th>Arr Time</th>
|
||||||
<th>Notes</th>
|
<th>Notes</th>
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
(Alt: {!! $flight->alt_airport->icao !!})
|
(Alt: {!! $flight->alt_airport->icao !!})
|
||||||
@endif
|
@endif
|
||||||
</td>
|
</td>
|
||||||
<td>{!! $flight->route !!}</td>
|
{{--<td>{!! $flight->route !!}</td>--}}
|
||||||
<td>{!! $flight->dpt_time !!}</td>
|
<td>{!! $flight->dpt_time !!}</td>
|
||||||
<td>{!! $flight->arr_time !!}</td>
|
<td>{!! $flight->arr_time !!}</td>
|
||||||
<td>{!! $flight->notes !!}</td>
|
<td>{!! $flight->notes !!}</td>
|
||||||
|
|||||||
@@ -2,14 +2,16 @@
|
|||||||
|
|
||||||
@section('title', 'Users')
|
@section('title', 'Users')
|
||||||
@section('actions')
|
@section('actions')
|
||||||
<li>
|
<li><a href="{!! route('admin.users.index') !!}?search=state:0">
|
||||||
<a href="{!! route('admin.users.create') !!}">
|
<i class="ti-plus"></i>{!! PilotState::label(PilotState::PENDING) !!}</a>
|
||||||
<i class="ti-plus"></i>
|
|
||||||
Add New</a>
|
|
||||||
</li>
|
</li>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
|
<div class="card">
|
||||||
|
@include('admin.users.search')
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
@include('admin.users.table')
|
@include('admin.users.table')
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<div class="content">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<div class="form-group">
|
||||||
|
{!! Form::open(['route' => 'admin.users.index', 'method' => 'GET', 'class'=>'form-inline pull-right']) !!}
|
||||||
|
|
||||||
|
{!! Form::label('name', 'Name:') !!}
|
||||||
|
{!! Form::text('name', null, ['class' => 'form-control']) !!}
|
||||||
|
|
||||||
|
{!! Form::label('email', 'Email:') !!}
|
||||||
|
{!! Form::text('email', null, ['class' => 'form-control']) !!}
|
||||||
|
|
||||||
|
{{--{!! Form::label('dep_icao', 'Departure:') !!}
|
||||||
|
{!! Form::select('dep_icao', $airports, null , ['class' => 'form-control']) !!}
|
||||||
|
|
||||||
|
{!! Form::label('arr_icao', 'Arrival:') !!}
|
||||||
|
{!! Form::select('arr_icao', $airports, null , ['class' => 'form-control']) !!}
|
||||||
|
--}}
|
||||||
|
{!! Form::submit('find', ['class' => 'btn btn-primary']) !!}
|
||||||
|
|
||||||
|
<a href="{!! route('admin.users.index') !!}">clear</a>
|
||||||
|
{!! Form::close() !!}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
Reference in New Issue
Block a user