<?php
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\HomeController;
use App\Http\Controllers\AdminController;
use App\Http\Controllers\AgentController;
use App\Http\Controllers\ManagerController;
use App\Http\Controllers\PatientController;
use App\Http\Controllers\LeadController;

//Route::get('/api/leads', [LeadController::class, 'getAllFacebookLead']);
//Route::post('/api/leads', [LeadController::class, 'createLead']);
//Route::post('/webhook', [LeadController::class, 'webhook']);
#Route::post('/webhookPost', [LeadController::class, 'webhookPost']);

// Route::get('/webhook', function (Request $request) {
//     $mode = $request->query('hub_mode');
//     $token = $request->query('hub_verify_token');
//     $challenge = $request->query('hub_challenge');
    
//     if ($mode && $token) {
//         if ($mode === 'subscribe' && $token === 'kbjhdsaufgvvhascdhf') {
//             Log::info('Webhook verification Successfully.');
//             return response($challenge, 200);
//         } else {
//              Log::warning('Webhook verification failed.');
//             return response('', 403);
//         }
//     }
// });


use App\Models\Role;
Route::get('/', function () {
    return view('auth.login');
});

Route::group(['prefix' =>'superadmin','middleware'=>'superadmin'], function() {
    Route::get('/', [HomeController::class, 'index']);
    Route::get('/create', [HomeController::class, 'create']);  
    Route::post('/create_post', [HomeController::class, 'createPost']);
    Route::get('/profile', [HomeController::class, 'Profile']);
    Route::post('/updateProfile', [HomeController::class, 'updateProfile']);  
    Route::get('/role', function(){ $roledata= Role::get(); return view('role')->with(['roledata'=>$roledata]);});  
    Route::post('/addRole', [HomeController::class, 'addRole']);
    Route::get('/delete/{id}', [HomeController::class, 'delete']);  
    Route::get('/userdelete/{id}', [HomeController::class, 'Userdelete']); 
    Route::get('/smLeads', [LeadController::class, 'SocialMediaLeads']);
    Route::get('/waLeads', [LeadController::class, 'WhatsaapLeads']); 
    Route::get('/roleList', [HomeController::class, 'roleList']); 
});

Route::group(['prefix' =>'admin','middleware'=>'superadmin'], function() {
    Route::get('/', [AdminController::class, 'index']);
    Route::get('/profile', [AdminController::class, 'Profile']);
    Route::post('/updateProfile', [AdminController::class, 'updateProfile']);
    Route::get('/delete/{id}', [AdminController::class, 'delete']);
    Route::get('/userdelete/{id}', [AdminController::class, 'Userdelete']); 
    Route::get('/smLeads', [LeadController::class, 'SocialMediaLeads']);
    Route::get('/waLeads', [LeadController::class, 'WhatsaapLeads']);
});

Route::group(['prefix' =>'manager','middleware'=>'manager'], function() {
    Route::get('/', [ManagerController::class, 'index']);
    Route::get('/profile', [ManagerController::class, 'Profile']);
    Route::post('/updateProfile', [ManagerController::class, 'updateProfile']);
    Route::get('/delete/{id}', [ManagerController::class, 'delete']);
    Route::get('/userdelete/{id}', [ManagerController::class, 'Userdelete']);
    
});

Route::group(['prefix' =>'patient','middleware'=>'patient'], function() {
    Route::get('/', [PatientController::class, 'index']);
    Route::get('/profile', [PatientController::class, 'Profile']);
    Route::post('/updateProfile', [PatientController::class, 'updateProfile']);
    Route::get('/delete/{id}', [PatientController::class, 'delete']);
    Route::get('/userdelete/{id}', [PatientController::class, 'Userdelete']);
    
});


Auth::routes();
Route::get('/home', [App\Http\Controllers\HomeController::class, 'index']);
Auth::routes();

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