<?php

use Illuminate\Support\Facades\Artisan;
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('/clear-cache', function() {
    $run = Artisan::call('migrate');
    $run = Artisan::call('config:clear');
    $run = Artisan::call('cache:clear');
    $run = Artisan::call('config:cache');
    $run = Artisan::call('route:clear');
    $run = Artisan::call('view:clear');
    $run = Artisan::call('optimize:clear');
    // $run = Artisan::call('db:seed --class=PermissionTableSeeder');
    // $run = Artisan::call('migrate:fresh');
    $run = Artisan::call('db:seed');
    // $run = Artisan::call('db:seed --class=CreateSuperAdminSeeder');
    return 'FINISHED';  
});



// Route::get('/', function () {
//     return view('welcome');
// })->name('home');


// FRONT Routes
Route::match(['get'], '/', 'AuthController@home')->name('home');
Route::match(['post'], '/employee-login', 'AuthController@employee_login')->name('employee-login');
Route::match(['get'], '/logout', 'AuthController@logout')->name('emp-logout');

Route::group(['middleware' => 'employees'], function () {
    Route::match(['get'], '/employee-update-profile', 'FrontPageController@employee_info')->name('employee-info');
    Route::match(['post'], '/employee-update-profile/{id}', 'FrontPageController@employee_update')->name('employee-info-update');
    Route::match(['get'], '/create-customer', 'FrontPageController@create_customer')->name('create-customer');
    Route::match(['post'], '/store-customer', 'FrontPageController@store_customer')->name('store-customer');
    Route::match(['get'], '/download-customer', 'FrontPageController@download_customer')->name('download-customer');
    Route::match(['get'], '/common-arts', 'FrontPageController@commonArts')->name('common-arts');
    Route::match(['get'], '/thank-you', 'FrontPageController@thank_you')->name('thank-you');
    route::match(['get'], '/steps','FrontPageController@steps')->name('steps');
});


Route::middleware(['auth:sanctum', 'verified'])->get('/dashboard', function () {
    return view('dashboard');
})->name('dashboard');

// Ajax Routes
Route::match(['post'], 'country', 'AjaxController@country')->name('country');
Route::match(['post'], 'state', 'AjaxController@state')->name('state');
Route::match(['post'], 'city', 'AjaxController@city')->name('city');
Route::match(['post'], 'reporting-user', 'AjaxController@reporting_user')->name('reporting-user');

// Admin Routes
Route::group(['middleware' => 'route-access'], function () {
Route::group(['prefix' => 'admin', 'namespace' => 'Admin'], function () {
	
	
	Route::get('/', 'AdminAuth@index')->name('admin.login');
	Route::get('/login', 'AdminAuth@loginRedirect')->name('admin.login.redirect');
	Route::get('/logout', 'AdminAuth@logout')->name('admin.logout');
	Route::post('/login', 'AdminAuth@check')->name('admin.login.check');


    Route::group(['middleware' => 'verifier'], function () {
        //Dashboard Routes
        Route::group(['prefix' => 'dashboard'], function () {
            Route::get('/', 'Dashboard@index')->name('admin.dashboard');
        });
        Route::match(['get'], '/profile', 'Dashboard@profileCreate')->name('admin.profile');
        Route::match(['post'], '/profile', 'Dashboard@profileStore')->name('admin.profile.store');
        
        
        //User
        Route::match(['get'], '/user/export', 'UserDetailController@export')->name('user.export');
        Route::match(['get'], '/user/data', 'UserDetailController@data')->name('user.data');
        Route::match(['get'], '/user/status/{id}', 'UserDetailController@status')->name('user.status');
        Route::match(['get'], '/user/delete/{id}', 'UserDetailController@delete')->name('user.delete');
        Route::resource("/user", "UserDetailController");

        //Roles
        Route::match(['get'], '/role/export', 'RoleController@export')->name('role.export');
        Route::match(['get' ,'post'], '/role/find', 'RoleController@findData')->name('role.find');
        Route::match(['get'], '/role/data', 'RoleController@data')->name('role.data');
        Route::match(['get'], '/role/status/{id}', 'RoleController@status')->name('role.status');
        Route::match(['get'], '/role/delete/{id}', 'RoleController@delete')->name('role.delete');
        Route::match(['get', 'post'], '/role/multi-delete', 'RoleController@multiDelete')->name('role.multi-delete');
        Route::resource("/role", "RoleController");

        //Permission
        Route::match(['get'], '/permission/data', 'PermissionController@data')->name('permission.data');
        Route::resource("/permission", "PermissionController");
        
        //Employee
        Route::match(['get'], '/employee/export', 'EmployeeController@export')->name('employee.export');
        Route::match(['get' ,'post'], '/employee/find', 'EmployeeController@findData')->name('employee.find');
        Route::match(['get'], '/employee/data', 'EmployeeController@data')->name('employee.data');
        Route::match(['get'], '/employee/status/{id}', 'EmployeeController@status')->name('employee.status');
        Route::match(['get'], '/employee/delete/{id}', 'EmployeeController@delete')->name('employee.delete');
        Route::match(['get', 'post'], '/employee/multi-delete', 'EmployeeController@multiDelete')->name('employee.multi-delete');
        Route::match(['get'], '/employee/import', 'EmployeeController@importEmployee')->name('employee.import');
        Route::match(['post'], '/employee/import', 'EmployeeController@importEmployee_store')->name('employee.import.store');
        Route::resource("/employee", "EmployeeController");
        //Lead
        Route::match(['get'], '/lead/export', 'LeadController@export')->name('lead.export');
        Route::match(['get' ,'post'], '/lead/find', 'LeadController@findData')->name('lead.find');
        Route::match(['get'], '/lead/data', 'LeadController@data')->name('lead.data');
        Route::match(['get'], '/lead/status/{id}', 'LeadController@status')->name('lead.status');
        Route::match(['get'], '/lead/delete/{id}', 'LeadController@delete')->name('lead.delete');
        Route::match(['post'], '/lead/uploadart/{id}', 'LeadController@uploadArt')->name('lead.uploadArt');
        Route::match(['get', 'post'], '/lead/multi-delete', 'LeadController@multiDelete')->name('lead.multi-delete');
        Route::resource("/lead", "LeadController");


        //Common art
        Route::match(['post'], '/common-art/import', 'CommonArtController@import')->name('common-art.import');
        Route::resource("/common-art", "CommonArtController");
    });
});


});
/**
 * 
 */