<?php

// API routes  for blog
Route::prefix('{guard}/blog')->group(function () {
    Route::get('blog/form/{element}', 'BlogAPIController@form');
    Route::resource('blog', 'BlogAPIController');
});

// Public routes for blog
Route::get('blogs/', 'BlogPublicController@index');
Route::get('blogs/{slug?}', 'BlogPublicController@show');

if (Trans::isMultilingual()) {
    Route::group(
        [
            'prefix' => '{trans}',
            'where'  => ['trans' => Trans::keys('|')],
        ],
        function () {
            // Guard routes for blogs
            Route::prefix('{guard}/blog')->group(function () {
                Route::get('blog/form/{element}', 'BlogAPIController@form');
                Route::apiResource('blog', 'BlogAPIController');
            });
            // Public routes for blogs
            Route::get('blog/Blog', 'BlogPublicController@getBlog');
        }
    );
}

// API routes  for category
Route::prefix('{guard}/blog')->group(function () {
    Route::get('category/form/{element}', 'CategoryAPIController@form');
    Route::resource('category', 'CategoryAPIController');
});

// Public routes for category
Route::get('blogs/', 'CategoryPublicController@index');
Route::get('blogs/{slug?}', 'CategoryPublicController@show');

if (Trans::isMultilingual()) {
    Route::group(
        [
            'prefix' => '{trans}',
            'where'  => ['trans' => Trans::keys('|')],
        ],
        function () {
            // Guard routes for blogs
            Route::prefix('{guard}/blog')->group(function () {
                Route::get('category/form/{element}', 'CategoryAPIController@form');
                Route::apiResource('category', 'CategoryAPIController');
            });
            // Public routes for blogs
            Route::get('blog/Category', 'CategoryPublicController@getCategory');
        }
    );
}

// API routes  for tag
Route::prefix('{guard}/blog')->group(function () {
    Route::get('tag/form/{element}', 'TagAPIController@form');
    Route::resource('tag', 'TagAPIController');
});

// Public routes for tag
Route::get('blogs/', 'TagPublicController@index');
Route::get('blogs/{slug?}', 'TagPublicController@show');

if (Trans::isMultilingual()) {
    Route::group(
        [
            'prefix' => '{trans}',
            'where'  => ['trans' => Trans::keys('|')],
        ],
        function () {
            // Guard routes for blogs
            Route::prefix('{guard}/blog')->group(function () {
                Route::get('tag/form/{element}', 'TagAPIController@form');
                Route::apiResource('tag', 'TagAPIController');
            });
            // Public routes for blogs
            Route::get('blog/Tag', 'TagPublicController@getTag');
        }
    );
}