Skip to content

Commit

Permalink
#16 Moved the routes for user and product into their own file
Browse files Browse the repository at this point in the history
  • Loading branch information
amitavroy committed Dec 28, 2024
1 parent 57ccc64 commit 4541770
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 14 deletions.
8 changes: 6 additions & 2 deletions bootstrap/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@

return Application::configure(basePath: dirname(__DIR__))
->withRouting(
web: __DIR__.'/../routes/web.php',
commands: __DIR__.'/../routes/console.php',
web: __DIR__ . '/../routes/web.php',
commands: __DIR__ . '/../routes/console.php',
health: '/up',
then: function () {
Route::middleware('web')->group(base_path('routes/products.php'));
Route::middleware('web')->group(base_path('routes/users.php'));
}
)
->withMiddleware(function (Middleware $middleware) {
$middleware->web(append: [
Expand Down
15 changes: 15 additions & 0 deletions routes/products.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

use App\Http\Controllers\ProductController;
use App\Http\Controllers\ProductImageUploadController;
use Illuminate\Support\Facades\Route;

Route::group(['middleware' => 'auth'], function () {
Route::resource('/product', ProductController::class);

Route::post('/product/feature-image/{product}', [ProductImageUploadController::class, 'store'])
->name('product.add-feature-image');

Route::delete('/product/feature-image/{product}', [ProductImageUploadController::class, 'destroy'])
->name('product.remove-feature-image');
});
23 changes: 23 additions & 0 deletions routes/users.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

use App\Http\Controllers\ProfilePicUploadController;
use App\Http\Controllers\UserController;
use App\Http\Controllers\UserPasswordChangeController;
use App\Http\Controllers\UserSettingController;
use Illuminate\Support\Facades\Route;

Route::group(['middleware' => 'auth'], function () {
Route::get('/user/profile', [UserSettingController::class, 'show'])
->name('user-profile.show');

Route::post('/user/profile', [UserSettingController::class, 'update'])
->name('user-profile.update');

Route::post('/user/password-change', UserPasswordChangeController::class)
->name('user.password.change');

Route::post('/user/profile-pic-upload', ProfilePicUploadController::class)
->name('user.profile-pic.upload');

Route::resource('/user', UserController::class);
});
17 changes: 5 additions & 12 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,22 @@
Route::group(['middleware' => 'auth'], function () {
Route::get('/', HomeController::class)->name('home');
Route::post('/logout', LogoutController::class)->name('logout');

Route::get('/user/profile', [UserSettingController::class, 'show'])->name('user-profile.show');
Route::post('/user/profile', [UserSettingController::class, 'update'])->name('user-profile.update');
Route::post('/user/password-change', UserPasswordChangeController::class)->name('user.password.change');
Route::post('/user/profile-pic-upload', ProfilePicUploadController::class)->name('user.profile-pic.upload');
Route::resource('/user', UserController::class);

Route::resource('/product', ProductController::class);
Route::post('/product/feature-image/{product}', ProductImageUploadController::class)->name('product.upload-image');

Route::resource('/customer', CustomerController::class)->only(['index', 'show']);
Route::resource('/order', OrderController::class)->only(['index', 'show']);

Route::resource('/notification', NotificationController::class)->only(['index', 'create', 'store', 'destroy']);
Route::post('/notification/mark-read', MarkNotificationReadController::class)->name('notification.mark-read');
});

Route::get('/private-image', function (Request $request) {
if (! $request->has('filename')) {
if (!$request->has('filename')) {
abort(404);
}

$filename = $request->input('filename');
$path = storage_path('app/private/'.$filename);
if (! Storage::exists($filename)) {
$path = storage_path('app/private/' . $filename);
if (!Storage::exists($filename)) {
abort(404);
}

Expand Down

0 comments on commit 4541770

Please sign in to comment.