<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\UserController;
use App\Http\Controllers\JobController;
use App\Http\Controllers\ApplyController;
use App\Http\Controllers\AdminController;
use Illuminate\Support\Facades\Auth;
/*
|--------------------------------------------------------------------------
| 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('/', function () {
//     return view('index');
// })->name('index');

Route::get('/', [JobController::class, 'index'])->name('index');
Route::get('/login', [UserController::class, 'login'])->name('login');
Route::get('/register', [UserController::class, 'register'])->name('register');
Route::post('/createuser', [UserController::class, 'reg'])->name('createuser');
Route::post('/authuser', [UserController::class, 'auth'])->name('authuser');
Route::get('/employers', [UserController::class, 'employers'])->name('employers');
Route::get('/candidates', [UserController::class, 'candidates'])->name('candidates');
Route::get('/user={user}', [UserController::class, 'user'])->name('user');
Route::get('/jobs', [JobController::class, 'jobs'])->name('jobs');
Route::get('/jobs_details={job}', [JobController::class, 'jobs_details'])->name('jobs_details');
Route::middleware('auth')->group(function () {
    Route::get('/edit_user={user}', [UserController::class, 'edit_user'])->name('edit_user');
    Route::post('/edituser={user}', [UserController::class, 'edituser'])->name('edituser');
    Route::get('/logout', [UserController::class, 'logout'])->name('logout');
    Route::post('/addapply={job}', [ApplyController::class, 'addapply'])->name('addapply'); 
}); 
Route::middleware('employer')->group(function () {
    Route::get('/add_job', [JobController::class, 'add_job'])->name('add_job');
    Route::post('/addjob', [JobController::class, 'addjob'])->name('addjob');
    Route::get('/edit_job={job}', [JobController::class, 'edit_job'])->name('edit_job');
    Route::post('/editjob={job}', [JobController::class, 'editjob'])->name('editjob');
    Route::get('/deletejob={job}', [JobController::class, 'deletejob'])->name('deletejob');
    Route::get('applys={job}', [ApplyController::class, 'applys'])->name('applys');
});
Route::middleware('admin')->group(function () {
    Route::post('/addcategory', [AdminController::class, 'addcategory'])->name('addcategory');
    Route::get('/edit_category={category}', [AdminController::class, 'edit_category'])->name('edit_category');
    Route::post('/editcategory={category}', [AdminController::class, 'editcategory'])->name('editcategory');
    Route::get('/admin', [AdminController::class, 'admin'])->name('admin');
    Route::post('/addcity', [AdminController::class, 'addcity'])->name('addcity');
    Route::get('/edit_city={city}', [AdminController::class, 'edit_city'])->name('edit_city');
    Route::post('/editcity={city}', [AdminController::class, 'editcity'])->name('editcity');
});



