<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\HomeController;
use App\Http\Controllers\Admin\AuthenticationController;
use App\Http\Controllers\Admin\BlogController;
use App\Http\Controllers\Admin\CareerController;
use App\Http\Controllers\Admin\ContactController;
use App\Http\Controllers\Admin\ProjectController;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "web" middleware group. Make something great!
|
*/

Route::controller(HomeController::class)->group(function (){
    Route::get('/', 'index');
    Route::get('/about', 'about');
    Route::get('/blog', 'blog');
    Route::get('/blog/post/{slug?}', 'blogDetail');
    Route::get('/career', 'career');
    Route::get('/projects', 'projects');
    Route::get('/services', 'services');
    Route::get('/project/details/{slug?}', 'projectDetails');
    Route::get('/career/details/{id?}', 'jobDetails');
    Route::get('/work', 'work');
    Route::get('/contact', 'contact');
    Route::post('/saveContact', 'saveContact');
});

Route::group(['prefix' => 'admin/'], function()
{
    Route::controller(AuthenticationController::class)->group(function (){
        Route::get('/login', 'index');
        Route::post('/login', 'login');
    });

    Route::group(['middleware' => ['admin']], function()
    {
        Route::controller(ProjectController::class)->group(function (){
            Route::get('/projects', 'index');
            Route::get('/project/save/{id?}', 'save');
            Route::post('/saveProject', 'saveProject');
            Route::post('/project/deleteProject', 'deleteProject');
        });

        Route::controller(BlogController::class)->group(function (){
            Route::get('/posts', 'index');
            Route::get('/post/save/{id?}', 'save');
            Route::post('/savePost', 'savePost');
            Route::post('/post/deletePost', 'deletePost');
        });

        Route::controller(CareerController::class)->group(function (){
            Route::get('/careers', 'index');
            Route::get('/career/save/{id?}', 'save');
            Route::post('/saveCareer', 'saveCareer');
            Route::post('/changeCareerStatus', 'changeStatus');
            Route::post('/career/deleteCareer', 'deleteCareer');
        });

        Route::controller(ContactController::class)->group(function (){
            Route::get('/contacts', 'index');
            Route::post('/contact/deleteContact', 'deleteContact');
        });

        Route::controller(AuthenticationController::class)->group(function (){
            Route::get('/logout', 'logout');
        });
    });
});
