I have rooms in hospital each of one has number of beds ( 1 or 2 or 3)
I want to reserve bed to certain patient how can I handle this in my project in easy way
rooms migration :
$table->increments('id');
$table->string('name');
$table->integer('floor');
$table->text('description');
$table->timestamps();
beds migration
Schema::create('beds', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('quality');
$table->string('charge');
$table->integer('room_id')->unsigned();;
$table->foreign('room_id')->references('id')->on('rooms')
->onUpdate('cascade')->onDelete('cascade');
$table->boolean('status');
$table->timestamps();
});
reservation migration
Schema::create('reservations', function (Blueprint $table) {
$table->increments('id');
$table->date('date_in');
$table->date('date_out');
$table->boolean('status');
$table->integer('patient_id')->unsigned();
$table->foreign('patient_id')->references('id')->on('patients');
$table->integer('bed_id')->unsigned();
$table->foreign('bed_id')->references('id')->on('beds');
$table->timestamps();
});
how can I check available beds ,
get Available beds and ensure that the bed is booked or not ??
how can I use event and listener to handle the booking ?