Filter out flights depending on the only_flights_from_current setting #174
This commit is contained in:
@@ -8,7 +8,9 @@
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Repositories\FlightRepository;
|
||||
use function foo\func;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
|
||||
use App\Models\Flight;
|
||||
@@ -17,13 +19,30 @@ use App\Models\UserBid;
|
||||
|
||||
class FlightService extends BaseService
|
||||
{
|
||||
protected $userSvc;
|
||||
protected $flightRepo, $userSvc;
|
||||
|
||||
public function __construct(UserService $userSvc)
|
||||
public function __construct(FlightRepository $flightRepo, UserService $userSvc)
|
||||
{
|
||||
$this->flightRepo = $flightRepo;
|
||||
$this->userSvc = $userSvc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter out any flights according to different settings
|
||||
* @param $user
|
||||
* @return FlightRepository
|
||||
*/
|
||||
public function filterFlights($user)
|
||||
{
|
||||
$where = [];
|
||||
if (setting('pilots.only_flights_from_current', false)) {
|
||||
$where['dpt_airport_id'] = $user->curr_airport_id;
|
||||
}
|
||||
|
||||
return $this->flightRepo
|
||||
->whereOrder($where, 'flight_number', 'asc');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter out subfleets to only include aircraft that a user has access to
|
||||
* @param $user
|
||||
|
||||
Reference in New Issue
Block a user