Hi, i'm currently developing a website, and added a feature to becoming a member. The admin can check the member historical booking, from the user_id on the member's table and customer_id from booking's table, if the user_id is the same as customer_id, it can get all the booking history. How to do it
The MemberController :
public function memberHistory(){
$booking = Booking::where('customer_id',$id)->first();
$member = Member::where('user_id', '=', $booking->customer_id)->get();
$bookings = Booking::all()
return view('Member/member_history', ['booking'=>$booking, 'member'=>$member, 'bookings'=>$bookings, 'layout'=>'memberHistory']);
}
The database structure of member :
public function up()
{
Schema::create('members', function (Blueprint $table) {
$table->id();
$table->bigInteger('user_id');
$table->string('name');
$table->string('email');
$table->timestamp('email_verified_at')->nullable();
$table->string('role')->default('member');
$table->string('member_code');
$table->timestamps();
});
}
The booking structure :
Schema::create('bravo_bookings', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('code',64)->nullable();
$table->integer('vendor_id')->nullable();
$table->integer('customer_id')->nullable();
$table->integer('payment_id')->nullable();
$table->string('gateway',50)->nullable();
$table->integer('object_id')->nullable();
$table->string('object_model',255)->nullable();
$table->dateTime('start_date')->nullable();
$table->dateTime('end_date')->nullable();
$table->decimal('total',10,2)->nullable();
$table->integer('total_guests')->nullable();
$table->string('currency',5)->nullable();
$table->string('status',30)->nullable();
$table->decimal('deposit',10,2)->nullable();
$table->string('deposit_type',30)->nullable();
$table->decimal('commission',10,2)->nullable();
$table->string('commission_type',150)->nullable();
$table->string('email',255)->nullable();
$table->string('first_name',255)->nullable();
$table->string('last_name',255)->nullable();
$table->string('phone',255)->nullable();
$table->string('address',255)->nullable();
$table->string('address2',255)->nullable();
$table->string('city',255)->nullable();
$table->string('state',255)->nullable();
$table->string('zip_code',255)->nullable();
$table->string('country',255)->nullable();
$table->text('customer_notes')->nullable();
// $table->integer('vendor_commission_percent')->nullable();
// $table->integer('vendor_commission_amount')->nullable();
$table->integer('create_user')->nullable();
$table->integer('update_user')->nullable();
$table->softDeletes();
$table->timestamps();
});