The site has the ticket search.
The search is performed in the following fields:
1) departure City
2) City of arrival
3) date of departure
4) date of arrival
5) a Checkbox to select the direction, in one direction or the ticket back/back.
Now, the search model contains the following conditions:
$query->andWhere(['status' => Flights::STATUS_ACTIVE])
->andWhere(['>=', 'date_start', $this->date_from ? strtotime($this->date_from . '00:00:00') : null])
->andWhere(['=', 'city_start_id', $this->city_from])
->andWhere(['=', 'city_end_id', $this->city_to]);
$query->andFilterWhere(['<=', 'date_end', $this->date_to ? strtotime($this->date_to . '23:59:59') : null])
->andFilterWhere(['=', 'airline_id', $this->airline])
->andFilterWhere(['in', 'airport_start_id', $this->airport_id])
->andFilterWhere(['in', 'airline_id', $this->company_id])
->andFilterWhere(['=', 'agent', $this->partner]);
The choice of direction is defined in the variable
// if the variable is equal to 1, then the tickets need to look for return if equal 2, the tickets look in one direction.
public $direction = 1;
If you are searching for a one-way ticket, then no problems, seems to work fine.
And here with search of tickets return challenge.
How to specify search terms?
Or introduction of flights in the database to make the connection between tickets there/back?
PS Actually I can't in your head, on what parameters search for return to do.
If the ticket "there", there are two dates, departure/arrival. But if you look for the ticket "back", the date is not clear how to do. Trip ticket should not look at the date of arrival, you need some interval...
In short, confused completely...