<?php

use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Auth;
use App\Http\Controllers\HomeController;
use App\Http\Controllers\userBackend;
use App\Http\Controllers\withdrawalBackend;
use App\Http\Controllers\depositBackend;
use App\Http\Controllers\settingsBackend;
use App\Http\Controllers\affliateBackend;
use App\Http\Controllers\notificationsBackend;
use Illuminate\Support\Facades\App;

/*
|--------------------------------------------------------------------------
| 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 redirect('login');
});

Route::get('/manage-contacts', function () {
    return view('contacts');
});

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

Route::get('/logout', function () {
    Auth::logout();
    return redirect('login');
});

Auth::routes();

Route::get('/home', [HomeController::class, 'index'])->name('home');

Route::group(['prefix' => 'users'], function ()
 {
    Route::get('all', [userBackend::class, 'allUsers']);
    Route::get('active', [userBackend::class, 'active']);
    Route::get('inactive', [userBackend::class, 'inActive']);
    Route::get('free_agents', [userBackend::class, 'freeAgents']);
    Route::get('user/{id}', [userBackend::class, 'getUser'])->name('viewuser');
    Route::post('updateuserdetails', [userBackend::class, 'updateUser'])->name('updateuser');
    Route::post('adduserbalance', [userBackend::class, 'addUserBalance'])->name('addbalance');
    Route::post('subtractuserbalance', [userBackend::class, 'subtractUserBalance'])->name('subtrbalance');
    Route::post('changeupline', [userBackend::class, 'changeUpline'])->name('changeupline');
    Route::post('changepassowrd', [userBackend::class, 'changePassword'])->name('changepassword');
    Route::post('sendemail', [userBackend::class, 'sendMail'])->name('sendmail');
    Route::get('all_investments', [userBackend::class, 'allInvestments'])->name('all_investments');

});

Route::group(['prefix' => 'withdrawals'], function () 
{
    Route::get('all', [withdrawalBackend::class, 'allCashouts']);
    Route::get('approved', [withdrawalBackend::class, 'approvedCashout'])->name('approvedcashout');
    Route::get('pending', [withdrawalBackend::class, 'pendingCashouts'])->name('pendingcashout');
    Route::post('approve', [withdrawalBackend::class, 'approveCashouts'])->name('approvecashout');
    Route::post('reject', [withdrawalBackend::class, 'rejectCashouts'])->name('rejectcashout');
    Route::get('rejected', [withdrawalBackend::class, 'rejectedCashout'])->name('rejectedcashout');
    Route::get('pay', [withdrawalBackend::class, 'payUser'])->name('payuser');

});


Route::group(['prefix' => 'deposits'], function () 
{
    Route::get('all', [depositBackend::class, 'allDeposits']);
    Route::get('approved', [depositBackend::class, 'approvedDeposits'])->name('approvedDeposits');
    Route::get('pending', [depositBackend::class, 'pendingDeposits'])->name('pendingDeposits');
    Route::get('rejected', [depositBackend::class, 'rejectedDeposits'])->name('rejectedDeposits');
});

Route::group(['prefix' => 'affiliates'], function ()
 {
    Route::get('all', [affliateBackend::class, 'allAffiliates']);
    Route::get('active', [affliateBackend::class, 'activeAffiliates'])->name('activeaffiliates');
    Route::get('dormant', [affliateBackend::class, 'dormantAffiliates'])->name('dormantaffiliates');
   
});