<?php

use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| 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::get('test', function () {
    return App\Models\Post::first()->body;
});

Auth::routes();

Route::prefix('admin')->middleware('auth')->group(function () {

    Route::get('/', [App\Http\Controllers\Admin\DashboardController::class, 'index'])->name('dashboard');

    Route::view('about', 'admin.about')->name('about');

    Route::get('users', [\App\Http\Controllers\Admin\UserController::class, 'index'])->name('users.index');

    Route::get('posts', [\App\Http\Controllers\Admin\PostController::class, 'index'])->name('posts.manage');

    Route::get('posts/edit/{post_id}', [\App\Http\Controllers\Admin\PostController::class, 'edit'])->name('posts.manage.edit');

    Route::get('posts/new', [\App\Http\Controllers\Admin\PostController::class, 'new'])->name('posts.manage.new');

    Route::get('profile', [\App\Http\Controllers\Admin\ProfileController::class, 'show'])->name('profile.show');
    Route::put('profile', [\App\Http\Controllers\Admin\ProfileController::class, 'update'])->name('profile.update');
});

Route::get('/', [App\Http\Controllers\Front\HomeController::class, 'index'])->name('home');

Route::get('/{country}', [App\Http\Controllers\Front\HomeController::class, 'country'])->name('home.country');

Route::get('/{country}/posts', [App\Http\Controllers\Front\HomeController::class, 'all'])->name('home.country.posts');

Route::get('/{country}/posts/{post_slug}', [App\Http\Controllers\Front\HomeController::class, 'post'])->name('home.country.post');

Route::get('/{country}/{category}', [App\Http\Controllers\Front\HomeController::class, 'countryCategory'])->name('home.country.category');
