Caching & search configuration in repository classes
This commit is contained in:
@@ -34,18 +34,16 @@ class PirepController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display a listing of the Pirep.
|
|
||||||
*
|
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return Response
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||||
|
* @throws \Prettus\Repository\Exceptions\RepositoryException
|
||||||
*/
|
*/
|
||||||
public function index(Request $request)
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
$criterea = new RequestCriteria($request);
|
$criterea = new RequestCriteria($request);
|
||||||
$this->pirepRepo->pushCriteria($criterea);
|
$this->pirepRepo->pushCriteria($criterea);
|
||||||
|
|
||||||
$pireps = $this->pirepRepo
|
$pireps = $this->pirepRepo->orderBy('created_at', 'desc')
|
||||||
->orderBy('created_at', 'desc')
|
|
||||||
->paginate();
|
->paginate();
|
||||||
|
|
||||||
return view('admin.pireps.index', [
|
return view('admin.pireps.index', [
|
||||||
@@ -64,11 +62,9 @@ class PirepController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store a newly created Pirep in storage.
|
|
||||||
*
|
|
||||||
* @param CreatePirepRequest $request
|
* @param CreatePirepRequest $request
|
||||||
*
|
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||||
* @return Response
|
* @throws \Prettus\Validator\Exceptions\ValidatorException
|
||||||
*/
|
*/
|
||||||
public function store(CreatePirepRequest $request)
|
public function store(CreatePirepRequest $request)
|
||||||
{
|
{
|
||||||
@@ -83,7 +79,6 @@ class PirepController extends BaseController
|
|||||||
* Display the specified Pirep.
|
* Display the specified Pirep.
|
||||||
*
|
*
|
||||||
* @param int $id
|
* @param int $id
|
||||||
*
|
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function show($id)
|
public function show($id)
|
||||||
@@ -104,7 +99,6 @@ class PirepController extends BaseController
|
|||||||
* Show the form for editing the specified Pirep.
|
* Show the form for editing the specified Pirep.
|
||||||
*
|
*
|
||||||
* @param int $id
|
* @param int $id
|
||||||
*
|
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function edit($id)
|
public function edit($id)
|
||||||
@@ -123,12 +117,10 @@ class PirepController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the specified Pirep in storage.
|
* @param $id
|
||||||
*
|
|
||||||
* @param int $id
|
|
||||||
* @param UpdatePirepRequest $request
|
* @param UpdatePirepRequest $request
|
||||||
*
|
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||||
* @return Response
|
* @throws \Prettus\Validator\Exceptions\ValidatorException
|
||||||
*/
|
*/
|
||||||
public function update($id, UpdatePirepRequest $request)
|
public function update($id, UpdatePirepRequest $request)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,19 +10,12 @@ class AircraftRepository extends BaseRepository implements CacheableInterface
|
|||||||
{
|
{
|
||||||
use CacheableRepository;
|
use CacheableRepository;
|
||||||
|
|
||||||
/**
|
protected $fieldSearchable = [
|
||||||
* @var array
|
'name' => 'like',
|
||||||
*/
|
'registration' => 'like',
|
||||||
protected $fieldSearchable
|
'active',
|
||||||
= [
|
];
|
||||||
'name',
|
|
||||||
'registration',
|
|
||||||
'active',
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Configure the Model
|
|
||||||
**/
|
|
||||||
public function model()
|
public function model()
|
||||||
{
|
{
|
||||||
return Aircraft::class;
|
return Aircraft::class;
|
||||||
|
|||||||
@@ -11,17 +11,11 @@ class AirlineRepository extends BaseRepository implements CacheableInterface
|
|||||||
{
|
{
|
||||||
use CacheableRepository;
|
use CacheableRepository;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $fieldSearchable = [
|
protected $fieldSearchable = [
|
||||||
'code',
|
'code',
|
||||||
'name'
|
'name' => 'like',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
|
||||||
* Configure the Model
|
|
||||||
**/
|
|
||||||
public function model()
|
public function model()
|
||||||
{
|
{
|
||||||
return Airline::class;
|
return Airline::class;
|
||||||
|
|||||||
@@ -11,24 +11,13 @@ class AirportRepository extends BaseRepository implements CacheableInterface
|
|||||||
{
|
{
|
||||||
use CacheableRepository;
|
use CacheableRepository;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $fieldSearchable = [
|
protected $fieldSearchable = [
|
||||||
'icao'
|
'icao',
|
||||||
|
'name' => 'like',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
|
||||||
* Configure the Model
|
|
||||||
**/
|
|
||||||
public function model()
|
public function model()
|
||||||
{
|
{
|
||||||
return Airport::class;
|
return Airport::class;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create(array $attributes)
|
|
||||||
{
|
|
||||||
//$attributes['id'] = $attributes['icao'];
|
|
||||||
return parent::create($attributes);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,11 @@ use Illuminate\Validation\Validator;
|
|||||||
|
|
||||||
abstract class BaseRepository extends \Prettus\Repository\Eloquent\BaseRepository {
|
abstract class BaseRepository extends \Prettus\Repository\Eloquent\BaseRepository {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $id
|
||||||
|
* @param array $columns
|
||||||
|
* @return mixed|void
|
||||||
|
*/
|
||||||
public function findWithoutFail($id, $columns = ['*'])
|
public function findWithoutFail($id, $columns = ['*'])
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@@ -16,6 +21,10 @@ abstract class BaseRepository extends \Prettus\Repository\Eloquent\BaseRepositor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $values
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
public function validate($values)
|
public function validate($values)
|
||||||
{
|
{
|
||||||
$validator = Validator::make(
|
$validator = Validator::make(
|
||||||
|
|||||||
@@ -3,24 +3,19 @@
|
|||||||
namespace App\Repositories;
|
namespace App\Repositories;
|
||||||
|
|
||||||
use App\Models\Fare;
|
use App\Models\Fare;
|
||||||
|
use Prettus\Repository\Contracts\CacheableInterface;
|
||||||
|
use Prettus\Repository\Traits\CacheableRepository;
|
||||||
|
|
||||||
class FareRepository extends BaseRepository
|
class FareRepository extends BaseRepository implements CacheableInterface
|
||||||
{
|
{
|
||||||
/**
|
use CacheableRepository;
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $fieldSearchable = [
|
protected $fieldSearchable = [
|
||||||
'code',
|
'code' => 'like',
|
||||||
'name',
|
'name' => 'like',
|
||||||
'price',
|
'notes' => 'like',
|
||||||
'cost',
|
|
||||||
'notes',
|
|
||||||
'active'
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
|
||||||
* Configure the Model
|
|
||||||
**/
|
|
||||||
public function model()
|
public function model()
|
||||||
{
|
{
|
||||||
return Fare::class;
|
return Fare::class;
|
||||||
|
|||||||
@@ -10,9 +10,6 @@ class FlightRepository extends BaseRepository implements CacheableInterface
|
|||||||
{
|
{
|
||||||
use CacheableRepository;
|
use CacheableRepository;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $fieldSearchable = [
|
protected $fieldSearchable = [
|
||||||
'arr_airport_id',
|
'arr_airport_id',
|
||||||
'dpt_airport_id',
|
'dpt_airport_id',
|
||||||
@@ -21,9 +18,6 @@ class FlightRepository extends BaseRepository implements CacheableInterface
|
|||||||
'notes' => 'like',
|
'notes' => 'like',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
|
||||||
* Configure the Model
|
|
||||||
**/
|
|
||||||
public function model()
|
public function model()
|
||||||
{
|
{
|
||||||
return Flight::class;
|
return Flight::class;
|
||||||
|
|||||||
@@ -6,16 +6,10 @@ use App\Models\PirepField;
|
|||||||
|
|
||||||
class PirepFieldRepository extends BaseRepository
|
class PirepFieldRepository extends BaseRepository
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $fieldSearchable = [
|
protected $fieldSearchable = [
|
||||||
'name'
|
'name' => 'like',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
|
||||||
* Configure the Model
|
|
||||||
**/
|
|
||||||
public function model()
|
public function model()
|
||||||
{
|
{
|
||||||
return PirepField::class;
|
return PirepField::class;
|
||||||
|
|||||||
@@ -4,19 +4,17 @@ namespace App\Repositories;
|
|||||||
|
|
||||||
use App\Models\Pirep;
|
use App\Models\Pirep;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use Prettus\Repository\Contracts\CacheableInterface;
|
||||||
|
use Prettus\Repository\Traits\CacheableRepository;
|
||||||
|
|
||||||
class PirepRepository extends BaseRepository
|
class PirepRepository extends BaseRepository implements CacheableInterface
|
||||||
{
|
{
|
||||||
/**
|
use CacheableRepository;
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $fieldSearchable = [
|
protected $fieldSearchable = [
|
||||||
'user_id'
|
'user_id'
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
|
||||||
* Configure the Model
|
|
||||||
**/
|
|
||||||
public function model()
|
public function model()
|
||||||
{
|
{
|
||||||
return Pirep::class;
|
return Pirep::class;
|
||||||
|
|||||||
@@ -10,16 +10,10 @@ class RankRepository extends BaseRepository implements CacheableInterface
|
|||||||
{
|
{
|
||||||
use CacheableRepository;
|
use CacheableRepository;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $fieldSearchable = [
|
protected $fieldSearchable = [
|
||||||
|
'name' => 'like',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
|
||||||
* Configure the Model
|
|
||||||
**/
|
|
||||||
public function model()
|
public function model()
|
||||||
{
|
{
|
||||||
return Rank::class;
|
return Rank::class;
|
||||||
|
|||||||
@@ -3,19 +3,18 @@
|
|||||||
namespace App\Repositories;
|
namespace App\Repositories;
|
||||||
|
|
||||||
use App\Models\Subfleet;
|
use App\Models\Subfleet;
|
||||||
|
use Prettus\Repository\Contracts\CacheableInterface;
|
||||||
|
use Prettus\Repository\Traits\CacheableRepository;
|
||||||
|
|
||||||
class SubfleetRepository extends BaseRepository
|
class SubfleetRepository extends BaseRepository implements CacheableInterface
|
||||||
{
|
{
|
||||||
/**
|
use CacheableRepository;
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $fieldSearchable = [
|
|
||||||
|
|
||||||
|
protected $fieldSearchable = [
|
||||||
|
'name' => 'like',
|
||||||
|
'type' => 'like',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
|
||||||
* Configure the Model
|
|
||||||
**/
|
|
||||||
public function model()
|
public function model()
|
||||||
{
|
{
|
||||||
return Subfleet::class;
|
return Subfleet::class;
|
||||||
|
|||||||
@@ -2,19 +2,20 @@
|
|||||||
namespace App\Repositories;
|
namespace App\Repositories;
|
||||||
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use Prettus\Repository\Contracts\CacheableInterface;
|
||||||
|
use Prettus\Repository\Traits\CacheableRepository;
|
||||||
|
|
||||||
class UserRepository extends BaseRepository
|
class UserRepository extends BaseRepository implements CacheableInterface
|
||||||
{
|
{
|
||||||
/**
|
use CacheableRepository;
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $fieldSearchable = [
|
protected $fieldSearchable = [
|
||||||
'email'
|
'name' => 'like',
|
||||||
|
'email' => 'like',
|
||||||
|
'home_airport_id',
|
||||||
|
'curr_airport_id',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
|
||||||
* Configure the Model
|
|
||||||
**/
|
|
||||||
public function model()
|
public function model()
|
||||||
{
|
{
|
||||||
return User::class;
|
return User::class;
|
||||||
|
|||||||
Reference in New Issue
Block a user