<?php

use App\Http\Controllers\ProfileController;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\PixabayController;
use App\Http\Controllers\NewsController;

route::prefix('news')->group(function () {
        Route::get('/', [NewsController::class, 'index'])->name('news.index');
    Route::get('/latest', [NewsController::class, 'latestNews'])->name('news.latest');
Route::get('/news/{id}', [NewsController::class, 'show'])->name('news.show');
});
Route::get('/latest-news', [NewsController::class, 'latestNews']);


Route::get('/', function () {
    return view('welcome');
});

Route::get('/dashboard', function () {
    return view('dashboard');
})->middleware(['auth', 'verified'])->name('dashboard');

Route::middleware('auth')->group(function () {
    Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit');
    Route::patch('/profile', [ProfileController::class, 'update'])->name('profile.update');
    Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy');
});


Route::middleware(['auth'])->group(function () {
    Route::get('/pixabay', [PixabayController::class, 'index'])->name('pixabay.index');
    Route::get('/pixabay/search', [PixabayController::class, 'search'])->name('pixabay.search');
});

require __DIR__.'/auth.php';
