<?php

use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return redirect('login');
});

Auth::routes();

Route::get('logout', 'App\Http\Controllers\Auth\LoginController@logout')->name('logout');


Route::group(['namespace' => 'App\Http\Controllers'], function() {
    
    // HomeController
    Route::get('home', 'HomeController@index')->name('home');
    Route::post('check-email', 'HomeController@checkEmail')->name('check-email');
    Route::post('get-terms-service', 'HomeController@getTermsService')->name('get-terms-service');
    
});

Route::group(['namespace' => 'App\Http\Controllers','middleware'=>['auth']], function() {
    
    // HomeController
    Route::get('{path}/admin-login/{id}', 'HomeController@adminLogin');
    Route::get('back-to-admin', 'HomeController@backToAdmin');
    Route::get('storage/{folder}/{filename}', 'HomeController@displayImage');
    Route::get('storage/request_images/{userId}/{mainId}/{filename}', 'HomeController@displayRequestImage');
    Route::get('storage/profile_pictures/{folderName}/{userId}/{filename}', 'HomeController@displayProfileImage');
    
    // DashboardController
    Route::get('dashboard', 'DashboardController@index')->name('dashboard');
    
    // EditProfileController
    Route::get('edit-profile', 'EditProfileController@edit')->name('edit-profile');
    Route::post('update-profile', 'EditProfileController@update')->name('update-profile');
    Route::post('change-password', 'EditProfileController@changePassword')->name('change-password');
    
});

Route::group(['prefix' => '/admin','namespace' => 'App\Http\Controllers\Admin','as'=>'admin.','middleware'=>['auth']], function() {
    
    //AdminsController
    Route::resource('admins', 'AdminsController');
    Route::post('admins-status', 'AdminsController@status');
    
    //RealtorsController
    Route::resource('realtors', 'RealtorsController');
    Route::post('realtors-status', 'RealtorsController@status');
    Route::post('select-region', 'RealtorsController@selectRegion');
    Route::post('select-city', 'RealtorsController@selectCity');
    Route::post('profile-picture-remove', 'RealtorsController@removeProfile');
    Route::post('city-coordinates', 'RealtorsController@getCityCoordinates');
    Route::post('fetch-nearby-places', 'RealtorsController@fetchNearbyPlaces');
    
    //CustomersController
    Route::resource('customers', 'CustomersController');
    Route::post('customers-status', 'CustomersController@status');
    Route::post('remove-profile-picture', 'CustomersController@removeProfilePicture');
    
    //ProvincesController
    Route::resource('provinces', 'ProvincesController');
    Route::post('province-status','ProvincesController@status');
    
    //RegionsController
    Route::get('regions/{provinceId}','RegionsController@index');
    Route::get('regions/{provinceId}/create','RegionsController@create')->name('regions.create');
    Route::post('regions-store','RegionsController@store')->name('regions.store');
    Route::get('regions/{id}/edit','RegionsController@edit');
    Route::put('regions-update/{id}','RegionsController@update')->name('regions.update');
    Route::post('delete-regions', 'RegionsController@destroy');
    
    //CityController
    Route::get('city/{regionId}','CityController@index');
    Route::get('city/{regionId}/create','CityController@create')->name('city.create');
    Route::post('city-store','CityController@store')->name('city.store');
    Route::get('city/{id}/edit','CityController@edit');
    Route::put('city-update/{id}','CityController@update')->name('city.update');
    Route::post('delete-city', 'CityController@destroy');
    
    // BuyerRequestController
    Route::resource('buyer-request', 'BuyerRequestController');
    Route::get('edit-buyer-request/{id}', 'BuyerRequestController@edit');
    Route::post('update-buyer-request', 'BuyerRequestController@update')->name('buyer-request.update');
    // Route::post('buyer-change-location', 'BuyerRequestController@changeLocation');
    Route::post('get-location-list', 'BuyerRequestController@getLocationList');
    
    // SellerRequestController
    Route::resource('seller-request', 'SellerRequestController');
     Route::get('edit-seller-request/{id}', 'SellerRequestController@edit');
    Route::post('update-seller-request', 'SellerRequestController@update')->name('seller-request.update');
    Route::post('seller-change-city', 'SellerRequestController@sellerChangeCity');
    Route::post('remove-seller-image', 'SellerRequestController@removeImage');
    
    // HouseTypeController
    Route::resource('house-types', 'HouseTypeController');
    Route::post('house-type-status','HouseTypeController@status');
    
    // HeatingFuelController
    Route::resource('heating-fuels', 'HeatingFuelController');
    Route::post('heating-fuel-status','HeatingFuelController@status');
    
    // AmenitiesController
    Route::resource('amenities', 'AmenitiesController');
    Route::post('amenities-status','AmenitiesController@status');
    
    // AgePropertyController
    Route::resource('age-property', 'AgePropertyController');
    Route::post('age-property-status','AgePropertyController@status');
    
    // SqftPropertyController
    Route::resource('sqft-property', 'SqftPropertyController');
    Route::post('sqft-property-status','SqftPropertyController@status');
    
    // ParkingsController
    Route::resource('parkings', 'ParkingsController');
    Route::post('parking-status','ParkingsController@status');
    
    // BedroomsController
    Route::resource('bedrooms', 'BedroomsController');
    Route::post('bedroom-status','BedroomsController@status');
    
    // BathroomsController
    Route::resource('bathrooms', 'BathroomsController');
    Route::post('bathroom-status','BathroomsController@status');
    
    // CmsController
    Route::resource('cms', 'CmsController');
    Route::post('cms-status','CmsController@status');

    // TermsConditionsController
    Route::resource('terms-conditions', 'TermsConditionsController');
    
    // LanguagesController
    Route::resource('languages', 'LanguagesController');
    Route::post('languages-status', 'LanguagesController@status');
    
    // RealtorYearsController
    Route::resource('realtor-years', 'RealtorYearsController');
    Route::post('realtor-years-status', 'RealtorYearsController@status');

});
