简体   繁体   中英

Laravel project hosting error in heroku using postgreSQL

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 on Heroku 在此处输入图片说明

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>

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM