0

I'm making a flight reservation in laravel and I published it on Heroku. I used MySQL for the database when I was on the development, but when I want to publish it on Heroku, they dont have MySQL so I used PostgreSQL. I watched some videos on how to host it using that database.

When I was done, I can do CRUD in the hosting site but when Im going to filter the flight schedules it gives me an error. But when I do a search in my localhost, It doesnt have any errors.

I think this error is in the I used which is PostgreSQL. How can I fix this?

The result when I search on localhost The result when I search

The result when I search on Heroku enter image description here

My filter method in the controller.

FlightsController.php

 public function searchFlights(Request $request){
        $flights =  Flights::where('flight_country_from', 'like', '%' . $request->flightFrom . '%')
            ->where('flight_country_from', 'like', '%' . $request->flightFrom . '%')
            ->where('flight_country_to', 'like', '%' . $request->flightTo . '%')
            ->whereDate('flight_schedule', 'like', '%' . $request->flightDepart . '%')
            ->paginate(5);

            return view('airways.flightresult', compact('flights'));

    }

my search form

Search.blade.php

    <div class="tab-pane fade" id="flights" role="tabpanel" aria-labelledby="flights-tab">
          <h2 class="text-4 mb-3">Book Domestic and International Flights</h2>
          <form method="GET"  autocomplete="off" id="bookingFlight" action="{{url("/flightSearch")}}">
          {{ csrf_field() }}
          <div class="form-row">
             <div class="col-md-8 col-lg-3 form-group">
                <input class="form-control" type="text" name="flightFrom" id="flightFrom"  placeholder="From">
                <span class="icon-inside"><i class="fas fa-map-marker-alt"></i></span>
             </div>
             <div class="col-md-8 col-lg-3 form-group">
                <input class="form-control" type="text"  name="flightTo" id="flightTo"  placeholder="To">
                <span class="icon-inside"><i class="fas fa-map-marker-alt"></i></span>
             </div>
             <div class="col-md-8 col-lg-3 form-group">
                <input class="form-control" name="flightDepart"  id="flightDepart" required required placeholder="Departure Date">
                <span class="icon-inside"><i class="far fa-calendar-alt"></i></span>
             </div>
             <div class="col-md-12 form-group">
                <button class="btn btn-primary btn-block" type="submit">Search</button>
             </div>
          </div>
          </form>
       </div>
    </div>
2
  • "whereDate('flight_schedule', 'like', '%' . $request->flightDepart . '%')" What exactly are you trying to achieve with this line? Should not it be whereDate('flight_schedule', '=',$request->flightDepart) or something like this? Commented Sep 10, 2019 at 3:58
  • its a syntax for my filtering sir. Commented Sep 10, 2019 at 6:47

1 Answer 1

1

I strongly advise you to use the same database in development and production. MySQL and PostgreSQL aren't drop-in replacements for each other.

Either

  • switch to Postgres locally, reproduce the error, and fix it, or
  • use a supported MySQL add-on like ClearDB or JawsDB in production.
Sign up to request clarification or add additional context in comments.

2 Comments

If I use ClearDB it requires me to pay. Maybe the solution for this sir is to find a free hosting that supports mysq? Am I right?
@Vince, yes, either choose a free provider or pay for one. ClearDB and JawsDB both have a free tier but it's fairly limited so maybe that's not enough for you. Amazon RDS supports MySQL and its free tier is more generous. There are certainly other options too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.