master_template/routes/web.php

113 lines
4.1 KiB
PHP
Raw Normal View History

2024-06-10 12:21:58 +00:00
<?php
use App\Http\Controllers\FileController;
use App\Http\Controllers\FormsController;
use App\Http\Controllers\GeneralFormController;
use App\Http\Controllers\ProfileController;
use App\Http\Controllers\WebsiteController;
use App\Models\Enquiries;
use Illuminate\Support\Facades\Route;
use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Component\Process\Process;
/*
|--------------------------------------------------------------------------
| 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::post('/form/submit', [FormsController::class, 'handleFormSubmission'])->name("form.submit");
require __DIR__ . '/auth.php';
Route::middleware('auth')->group(function () {
Route::post('/upload', [FileController::class, 'upload'])->name('upload');
Route::group(['prefix' => 'files', 'middleware' => ['web', 'auth']], function () {
\UniSharp\LaravelFilemanager\Lfm::routes();
});
Route::middleware('auth')->get('/dashboard', function () {
return view('backend.dashboard');
});
Route::middleware('auth')->prefix('admin')->group(function () {
Route::get('/dashboard', function () {
return view('backend.dashboard');
});
Route::get('/', function () {
return view('backend.dashboard');
})->name('admin.dashboard');
Route::get('/backup', function () {
$databaseName = env('DB_DATABASE');
$backupFileName = 'backup_' . date('Y-m-d_His') . '.sql';
$backupPath = storage_path('app/' . $backupFileName);
// Create the mysqldump command as an array
$command = [
'mysqldump',
'--user=' . env('DB_USERNAME'),
'--password=' . env('DB_PASSWORD'),
'--host=' . env('DB_HOST'),
$databaseName,
];
// Run the mysqldump command using Symfony Process
$process = new Process($command);
$process->setOutputFile($backupPath);
$process->run();
if (!$process->isSuccessful()) {
throw new ProcessFailedException($process);
}
// Provide the download link for the backup file
return response()->download($backupPath)->deleteFileAfterSend(true);
})->name('backup.db');
});
Route::prefix("form")->group(function () {
Route::get('/tables', [GeneralFormController::class, 'tables'])->name('form.tables');
Route::get('/', [GeneralFormController::class, 'create'])->name('form.create');
Route::get('/store', [GeneralFormController::class, 'store'])->name('form.store');
Route::get('/make-table-nullable', [GeneralFormController::class, 'getTableNullablecreate'])->name('table.create');
Route::get('/store', [GeneralFormController::class, 'store'])->name('form.store');
});
Route::get('/shortcodes', function () {
return view("backend.shortcodes");
})->name('shortcodes');
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');
//get all enquiries
Route::get('/all-enquiries', function () {
$data = Enquiries::where('status', 1)->latest()->with('class')->get();
return view('backend.enquiries-list', compact('data'));
})->name('enquiries-list');
Route::delete('/enquiry/destory/{id}', function ($id) {
$data = Enquiries::findOrFail($id)->delete();
return redirect()->back();
})->name('enquiry.destroy');
require __DIR__ . '/route.settings.php';
require __DIR__ . '/route.menulocations.php';
require __DIR__ . '/route.menuitems.php';
});
require __DIR__ . '/route.client.php';
Route::fallback([WebsiteController::class, 'fallback']);