<?php

use App\Http\Controllers\Api\HomeController;
use App\Http\Controllers\Api\ProjectsController as WebProjectsController;
use App\Http\Controllers\Dashboard\AuthController;
use App\Http\Controllers\Dashboard\ContactController;
use App\Http\Controllers\Dashboard\ProjectsController;
use App\Http\Controllers\Dashboard\RecentWorksController;
use App\Http\Controllers\Dashboard\ServicesController;
use App\Http\Controllers\Dashboard\SocialMediaController;
use App\Http\Controllers\Dashboard\StaticInfoController;
use App\Http\Controllers\Dashboard\WorksController;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
Route::prefix('/admin')->group(function ()
{
    Route::post('login', [AuthController::class, 'login']);
});

Route::middleware(['auth:sanctum'])->group( function ()
    {
        Route::prefix('/admin')->group(function ()
        {

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

            Route::prefix('/social_media')->controller(SocialMediaController::class)->group(function ()
            {
                Route::get('/', 'getAll');
                Route::post('/', 'create');    
                Route::put('/{id}', 'update');    
                Route::delete('/{id}', 'delete');
            });
            
            Route::prefix('/static_info')->controller(StaticInfoController::class)->group(function ()
            {   
                Route::get('/', 'getAll');
                Route::post('/', 'create');    
                Route::put('/{id}', 'update');    
                Route::delete('/{id}', 'delete');
            });
        
            Route::prefix('/projects')->controller(ProjectsController::class)->group(function ()
            {
                Route::get('/', 'getAll');
                Route::get('/{id}', 'getOne');
                Route::post('/', 'create');    
                Route::put('/{id}', 'update');    
                Route::delete('/{id}', 'delete');
            });
        
            
            Route::prefix('/works')->controller(WorksController::class)->group(function ()
            {
                Route::get('/', 'getAll');
                Route::post('/', 'create');
                Route::put('/{id}', 'update');
                Route::delete('/{id}', 'delete');
            });
        
        
            Route::prefix('/services')->controller(ServicesController::class)->group(function ()
            {
                Route::get('/', 'getAll');
                Route::post('/', 'create');    
                Route::put('/{id}', 'update');    
                Route::delete('/{id}', 'delete');
            });
        
            Route::prefix('/recent_works')->controller(RecentWorksController::class)->group(function ()
            {
                Route::get('/', 'getAll');
                Route::post('/', 'create');    
                Route::put('/{id}', 'update');    
                Route::delete('/{id}', 'delete');
            });
        
            Route::prefix('/contact')->controller(ContactController::class)->group(function ()
            {
                Route::get('/', 'getAll');
                Route::post('/', 'create');    
                Route::put('/{id}', 'update');    
                Route::delete('/{id}', 'delete');
            });

        });
    });



    // website

    Route::prefix('/home')->controller(HomeController::class)->group(function ()
    {
        Route::get('/', 'getAll');
    });

    Route::prefix('/project')->controller(WebProjectsController::class)->group(function ()
    {
        Route::get('/', 'getAll');
        Route::get('/{id}', 'getOne');
    });