<?php

Route::group(['namespace' => 'Admin', 'prefix' => 'admin-backsys/api', 'middleware' => ['is_app_access_authorized']], function () {
	Route::group(['namespace' => 'Api'], function () {
        /////////////////////////////////////////////////////
		// Login
    	Route::post('login', ['as' => 'api.admin.login', 'uses' => 'LoginController@login']);
    	/////////////////////////////////////////////////////

		/////////////////////////////////////////////////////
		// Admin
		Route::prefix('admin')->group(function () {
			Route::get('self', 
	    		[
					'as' => 'api.admin.self', 
					'uses' => 'AdminController@self', 
	    		]
	    	);
	    	Route::get('list', 
	    		[
					'as' => 'api.admin.list', 
					'uses' => 'AdminController@list', 
					'middleware' => ['permission:view admin']
	    		]
	    	);
	    	Route::get('show/{hash_id}', 
	    		[
					'as' => 'api.admin.show', 
					'uses' => 'AdminController@show', 
					'middleware' => ['permission:view admin']
	    		]
	    	);
	    	Route::post('store', 
	    		[
					'as' => 'api.admin.store', 
					'uses' => 'AdminController@store', 
					'middleware' => ['permission:add admin']
	    		]
	    	);
	    	Route::put('update/{hash_id}', 
	    		[
					'as' => 'api.admin.update', 
					'uses' => 'AdminController@update', 
					'middleware' => ['permission:edit admin']
	    		]
	    	);
	    	Route::post('valid-check/{hash_id?}', 
	    		[
					'as' => 'api.admin.valid-check', 
					'uses' => 'AdminController@validCheck', 
					'middleware' => ['permission:add admin']
	    		]
	    	);
		});
        /////////////////////////////////////////////////////
		
        /////////////////////////////////////////////////////
		// Permission
		Route::prefix('permission')->group(function () {
			Route::get('list', 
	    		[
					'as' => 'api.admin.permission.list', 
					'uses' => 'PermissionController@list', 
					'middleware' => ['permission:view permission']
	    		]
	    	);
		});
        /////////////////////////////////////////////////////
	});
});