<?php

namespace Modules\Posts\Config;

use Config;
// Create a new instance of our RouteCollection class.
$routes = Config\Services::routes();

// Load the system's routing file first, so that the app and ENVIRONMENT
// can override as needed.
if (is_file(SYSTEMPATH . 'Config/Routes.php')) {
    require SYSTEMPATH . 'Config/Routes.php';
}


//setting up Inventory routes.
$routes->group('administrator/posts', ['filter' => ['isLoggedIn',  'checkPermission'], 'namespace' => 'Modules\Posts\Controllers'],   static function($routes){

    $routes->get('/', 'Posts::index');
    $routes->get('add', 'Posts::addPost');
    $routes->post('add', 'Posts::addPost');
    $routes->get('edit/(:any)', 'Posts::editPost/$1');
    $routes->post('update', 'Posts::updatePost');
    $routes->get('view/(:any)', 'Posts::viewPost/$1');
    $routes->get('delete/(:any)', 'Posts::delPost/$1');

    $routes->get('block-posts', 'Posts::viewBlockPosts');
    $routes->get('block-post/add', 'Posts::addBlockPost');
    $routes->post('block-post/add', 'Posts::addBlockPost');
    $routes->get('block-post/edit/(:any)', 'Posts::editBlockPost/$1');
    $routes->post('block-post/update', 'Posts::updateBlockPost');
    $routes->get('block-post/view/(:any)', 'Posts::viewBlockPost/$1');
    $routes->get('block-post/delete/(:any)', 'Posts::delBlockPost/$1');

    $routes->post('block/save', 'BlockPosts::saveBlock');
    $routes->get('block/get-block/(:any)', 'BlockPosts::getBlock/$1');
    $routes->get('block/delete/(:any)', 'BlockPosts::deleteBlock/$1');

    $routes->post('block/items/save', 'BlockPosts::saveChildItem');
    $routes->get('block/items/get-block/(:any)', 'BlockPosts::getChildItem/$1');
    $routes->get('block/items/delete/(:any)', 'BlockPosts::deleteChildItem/$1');


    $routes->get('block-post/text/edit/(:num)', 'BlockPosts::editTextBlock/$1');
    $routes->get('block-post/heading/edit/(:num)', 'BlockPosts::editHeadingBlock/$1');
    $routes->get('block-post/list/edit/(:num)', 'BlockPosts::editListBlock/$1');
    $routes->get('block-post/image/edit/(:num)', 'BlockPosts::editImageBlock/$1');
    $routes->get('block-post/video/edit/(:num)', 'BlockPosts::editVideoBlock/$1');
    $routes->get('block-post/code/edit/(:num)', 'BlockPosts::editCodeBlock/$1');
    $routes->get('block-post/advertcode/edit/(:num)', 'BlockPosts::editAdvertCodeBlock/$1');

    $routes->post('block-post/text/update', 'BlockPosts::updateTextBlock');
    $routes->post('block-post/heading/update', 'BlockPosts::updateHeadingBlock');
    $routes->post('block-post/list/update', 'BlockPosts::updateListBlock');
    $routes->post('block-post/image/update', 'BlockPosts::updateImageBlock');
    $routes->post('block-post/video/update', 'BlockPosts::updateVideoBlock');
    $routes->post('block-post/code/update', 'BlockPosts::updateCodeBlock');
    $routes->post('block-post/advertcode/update', 'BlockPosts::updateAdvertCodeBlock');

    $routes->get('block-post/text/delete/(:num)', 'BlockPosts::deleteTextBlock/$1');
    $routes->get('block-post/heading/delete/(:num)', 'BlockPosts::deleteHeadingBlock/$1');
    $routes->get('block-post/list/delete/(:num)', 'BlockPosts::deleteListBlock/$1');
    $routes->get('block-post/image/delete/(:num)', 'BlockPosts::deleteImageBlock/$1');
    $routes->get('block-post/video/delete/(:num)', 'BlockPosts::deleteVideoBlock/$1');
    $routes->get('block-post/code/delete/(:num)', 'BlockPosts::deleteCodeBlock/$1');
    $routes->get('block-post/advertcode/delete/(:num)', 'BlockPosts::deleteAdvertCodeBlock/$1');

    $routes->get('categories', 'Posts::postCategories');
    $routes->post('categories/add', 'Posts::addCategory');
    $routes->get('categories/edit/(:any)', 'Posts::editCategory/$1');
    $routes->post('categories/update',  'Posts::updateCategory');
    $routes->get('categories/delete/(:any)', 'Posts::delCategory/$1');

    $routes->get('comments', 'Posts::allPostComments');
    $routes->post('comment/add', 'Posts::addPostComment');
    $routes->get('comment/edit/(:num)', 'Posts::editPostComment/$1');
    $routes->post('comment/update', 'Posts::updatePostComment');
    $routes->get('comment/delete/(:num)', 'Posts::deletePostComment/$1');

});
//For all pages routes
$routes->group('administrator/pages', ['filter' => ['isLoggedIn',  'checkPermission'], 'namespace' => 'Modules\Posts\Controllers'],   static function($routes){

    $routes->get('/', 'Pages::index');
    $routes->get('add', 'Pages::addPage');
    $routes->post('add', 'Pages::addPage');
    $routes->get('edit/(:any)', 'Pages::editPage/$1');
    $routes->post('update', 'Pages::updatePage');
    $routes->get('view/(:any)', 'Pages::viewPage/$1');
    $routes->get('delete/(:any)', 'Pages::delPage/$1');

    $routes->get('block-pages', 'Pages::viewBlockPages');
    $routes->get('block-page/add', 'Pages::addBlockPage');
    
});

//For all Tags routes
$routes->group('administrator/tags', ['filter' => 'isLoggedIn', 'namespace' => 'Modules\Posts\Controllers'],   static function($routes){

    $routes->get('/', 'Tags::index');
    $routes->get('list', 'Tags::getTagsList');
    $routes->get('check', 'Tags::checkTag');
    $routes->post('check', 'Tags::checkTag');
    $routes->get('add', 'Tags::addTag');
    $routes->post('add', 'Tags::addTag');
    $routes->get('edit/(:any)', 'Tags::editTag/$1');
    $routes->post('update', 'Tags::updateTag');
    $routes->get('delete/(:any)', 'Tags::delTag/$1');
    
});
