jeudi 4 juin 2020

i want to show just my hotel's reservation LARAVEL 7

thats Reservation Table it have hotel_id

Schema::create('reservations', function (Blueprint $table) {
        $table->id();
        $table->integer('user_id')->unsigned()->references('id')->on('users');
        $table->integer('hotel_id')->unsigned()->references('id')->on('hotel');
        $table->string('status')->default('pending');
        $table->integer('rooms');
        $table->date('checkin');
        $table->date('checkout');
        $table->timestamps();

i try getting just my hotels id and compare it with reservation hotel_id but not working

public function index()
{
    $myhotels = hotel::where('created_by',Auth::user()->id)->first('id');

 $reservations = Reservation::where('hotel_id',$myhotels)->get();

    return view('moderateur/reservation',compact('reservations'));
}


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire