<?php
/**
 * Created by PhpStorm.
 * User: stana
 * Date: 06.04.2017
 * Time: 19:28
 */

namespace App\Http\Controllers;


use Illuminate\Support\Facades\DB;
use Auth;

class CustomersController
{
    public function showCustomers(){
        $customers = DB::table('users')
            ->join('accommodations','accommodations.accommodation_id','=','users.accommodation_id')
            ->join('rooms','accommodations.accommodation_id','=','rooms.accommodation_id')
            ->join('reservations','rooms.room_id','=','reservations.room_id')
            ->join('customers','reservations.customer_id','=','customers.customer_id')
            ->where('users.user_id','=',Auth::user()->user_id)
            ->select('customers.customer_fname','customers.customer_lname','customers.customer_email', 'customers.customer_phone_number')
            ->distinct()
            ->get();

        return view('customers_list', ['customers' => $customers]);
    }
}