<?php

use App\Http\Controllers\ProfileController;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\MaterialController;
use App\Http\Controllers\ProductController;
use App\Http\Controllers\ProductionController;

Route::get('/', function () {
    return view('auth.login');
});

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('materials', MaterialController::class);
Route::resource('products', ProductController::class);

Route::get('/products/{product}/formula', [ProductController::class, 'formula'])
        ->name('products.formula');

Route::post('/products/{product}/formula', [ProductController::class, 'saveFormula'])
        ->name('products.saveFormula');

Route::resource('production', ProductionController::class);


require __DIR__.'/auth.php';
