<?php

use App\Http\Controllers\DashboardController;
use App\Http\Controllers\PriceController;
use App\Http\Controllers\ProductController;
use App\Http\Controllers\ProfileController;
use App\Http\Controllers\SaleController;
use App\Http\Controllers\UnitController;
use Illuminate\Support\Facades\Route;

Route::get('/', function () {
    return redirect('/dashboard');
});

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::resource('products', ProductController::class);
Route::resource('prices', PriceController::class);
Route::get(
    '/prices/{date}/edit-daily',
    [PriceController::class, 'editDaily']
);

Route::put(
    '/prices/{date}/update-daily',
    [PriceController::class, 'updateDaily']
);
Route::resource('sales', SaleController::class);
Route::get('/sales/{id}/receipt', [SaleController::class, 'receipt']);

Route::get('/dashboard', [DashboardController::class, 'index']);

Route::resource('units', UnitController::class);

require __DIR__ . '/auth.php';
