<?php

use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;


Route::get('migrate',function(){
    Artisan::call("db:wipe");
    Artisan::call("migrate");
    Artisan::call("db:seed");
    Artisan::call("storage:link");
});


Auth::routes();



Route::get('/', 'HomeController@index')->name('home');

Route::get('/result', 'HomeController@result');



Route::group(['as' => 'manager.','prefix' => 'manager', 'namespace' => 'Manager', 'middleware' => ['auth', 'manager']], function (){

    Route::get('/', 'ManagerController@index')->name('home');



    Route::get('/employees', 'ManagerController@employees')->name('all-employees');

    Route::get('api/employees', 'ManagerController@employeesData');



    Route::post('api/employee', 'ManagerController@storeEmployee' );

    Route::delete('api/employee/{id}', 'ManagerController@deleteEmployee' );

    Route::put('api/employee/{id}', 'ManagerController@editEmployee' );



    // Manager Orders List

    Route::get('/orders_page', 'ManagerController@ordersPage')->name('orders');

    Route::get('api/orders/{pageState}', 'ManagerController@getOrders');

    Route::get('api/orders/detail/{id}', 'ManagerController@viewOrderDetails');

    Route::get('api/orders/search/{search}/{pageState}', 'ManagerController@getSearchedOrders');

    Route::get('/seetting', 'ManagerController@setting')->name('setting');

    Route::post('/seetting', 'ManagerController@setting')->name('save-setting');

    Route::get('/excel', 'ManagerController@excel')->name('excel');

    Route::get('/employee_details/{id}', 'ManagerController@viewDetails');

});



// Employee Reciption Router

Route::group(['as' => 'rec.', 'prefix' => 'rec', 'namespace' => 'Reciption', 'middleware' => ['auth', 'reciption', 'isEnabled']], function(){

    Route::get('/', 'ReciptionController@index');

    Route::get('/home', 'ReciptionController@home')->name('home');

    Route::get('/stat', 'ReciptionController@stat')->name('stat');

    Route::get('/screen', 'ReciptionController@getOrdersForScreen');

    //New Order Page

    Route::get('/new_order', 'ReciptionController@NewOrder')->name('new-order');

    Route::post('/new_order', 'ReciptionController@NewOrder')->name('new-order-store');

    //get orders and display

    Route::get('/orders', 'ReciptionController@index')->name('index');

    Route::post('api/orders', 'ReciptionController@index');



    //update order {id} => customer id

    Route::put('api/orders', 'ReciptionController@updateOrder');

    // Cancel order {id} => order_id

    Route::put('api/order/cancel', 'ReciptionController@cancelOrder');

    // Search for client {name} => client name

    Route::get('api/order/search/{name}', 'ReciptionController@searchResult');

    // Change State to delivered {order} => order id

    Route::put('api/order/delv', 'ReciptionController@deleviredOrder');



    Route::get('/order/to/stock', 'ReciptionController@ordersSotck')->name('stock');

    // to stock order {order} => order_id

    Route::put('api/order/to/stock', 'ReciptionController@toStock');



    // stock page

    Route::get('/order/stock', 'ReciptionController@mainStock')->name('main-stock');

    Route::post('api/order/stock', 'ReciptionController@mainStock');



    Route::get('api/order/stock/{pageState}', 'ReciptionController@ordersSotckDevices');

    // view order details

    Route::get('api/order/{id}', 'ReciptionController@viewOrderDetails');



    Route::get('/excel', 'ReciptionController@excel')->name('excel');



    // brands

    Route::match(['get', 'post', 'put'],'/brands', 'ReciptionController@brands')->name('brands');

    Route::get('api/get_brands', 'ReciptionController@getBrands');

    Route::get('api/get_brands/{type}', 'ReciptionController@getBrandsType');

    Route::put('/done_notice', 'ReciptionController@doneNotice');

    Route::get('/print', 'ReciptionController@print')->name('print');
    Route::get('/print2', 'ReciptionController@print2')->name('print2');

    Route::get('/reset_print/{name}/{serial}/{phone}', 'ReciptionController@reset_print')->name('reset_print');

//    // Store new brand

//    Route::post('/brands', 'ReciptionController@brands');

});



// Employee Hardware Router

Route::group(['as' => 'hdc.', 'prefix' => 'hdc', 'namespace' => 'Hardware', 'middleware' => ['auth:web', 'hdc', 'isEnabled']], function (){

    Route::get('/', 'HardwareController@index')->name('home');

    Route::get('/screen', 'HardwareController@getOrdersForScreen');

    Route::get('/stat', 'HardwareController@stat')->name('stat');

    Route::get('/orders', 'HardwareController@ordersPage')->name('orders');

    Route::get('api/get_orders/{type}', 'HardwareController@getOrders')->name('get-orders');

    // order -> order id

    Route::put('api/accept_order', 'HardwareController@acceptOrder');

    // order -> order->id

    Route::put('api/work_done', 'HardwareController@finishedRepair');



});







// Employee Software Router

Route::group(['as' => 'swc.', 'prefix' => 'swc', 'namespace' => 'Software', 'middleware' => ['auth:web', 'swc', 'isEnabled']], function (){

    Route::get('/', 'SoftwareController@index')->name('home');

    Route::get('/screen', 'SoftwareController@getOrdersForScreen');



    Route::get('/stat', 'SoftwareController@stat')->name('stat');

    Route::get('/orders', 'SoftwareController@ordersPage')->name('orders');

    Route::get('api/get_orders/{type}', 'SoftwareController@getOrders')->name('get-orders');

    // order -> order id

    Route::put('api/accept_order', 'SoftwareController@acceptOrder');

    // order -> order->id

    Route::put('api/work_done', 'SoftwareController@finishedRepair');



});







// Employee Mobile Router

Route::group(['as' => 'mob.', 'prefix' => 'mob', 'namespace' => 'Mobile', 'middleware' => ['auth', 'mob', 'isEnabled']], function (){

    Route::get('/', 'MobileController@index')->name('home');

    Route::get('/stat', 'MobileController@stat')->name('stat');

    Route::get('/screen', 'MobileController@getOrdersForScreen');



    Route::get('/orders', 'MobileController@ordersPage')->name('orders');

    Route::get('api/get_orders/{type}', 'MobileController@getOrders')->name('get-orders');

    // order -> order id

    Route::put('api/accept_order', 'MobileController@acceptOrder');

    // order -> order->id

    Route::put('api/work_done', 'MobileController@finishedRepair');

});

