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