Hello @Mian Saleem, I just created a page and added it to the Side Menu. now it is only working with Super Admin. I have also created permissions and permitted the page to be opened by a normal user but it is not working throwing 403 Forbidden error. attached screenshot for details… Kindly Help Thank you
On menu:
{
name: ‘sorting.inboundcreate’,
route: ‘sorting.inboundcreate’,
icon: null,
hidden: false,
sub_menu: false,
permissions: [‘read-inbounds’, ‘create-inbounds’, ‘update-inbounds’],
lang: { helper: ‘create_x’, main: ‘Inbound’ },
},
- MSAnswered
Hello,
The permission in backend is handled by
Authorizable
trait and it is using the route name with action to check the permission and allow access to controller method. You should get the route name as Laravel dousers.index
,users.create
,users.show
…If you want to change, feel free to modify the trait as you need.
Thank you
- NAnswered
Dear Mian, I have tried changing the route according to the suggestion .ex, .create but I am failing somewhere and getting 403: Forbidden. Kindly help… some details for your reference:
Traits/Authorizable:
'read', 'show' => 'read', 'edit' => 'update', 'update' => 'update', 'create' => 'create', 'store' => 'create', 'destroy' => 'delete', 'destroy-many' => 'delete', 'destroy-permanently' => 'delete', 'delete' => 'delete', 'void' => 'delete', 'email' => 'email', 'disable2FA' => 'update', 'disable2-f-a' => 'update', 'change-password' => 'update', 'delete-attachment' => 'delete', 'payments' => 'payments', // check the sale/purchase payments 'generate' => 'create', // Custom method example 'archive' => 'update', // Custom method example ]; Web.php -------- Route::get('/sorting-inbound', [SortingWarehouseReceiptController::class, 'index'])->name('sortinginbound.index'); Route::get('/sorting-inbound/create', [SortingWarehouseReceiptController::class, 'create'])->name('sortinginbound.create'); SortingWarehouseReceiptController: ---------------------------------- get(); return inertia('SortingInbound/Index', [ 'receipts' => $receipts->map(function ($receipt) { \Log::info('Raw status_history:', ['status_history' => $receipt->status_history]); \Log::info('Decoded status_history:', ['decoded' => json_decode($receipt->status_history, true)]); return [ 'id' => $receipt->id, 'date' => $receipt->date, 'driver' => $receipt->driver ? [ 'id' => $receipt->driver->id, 'name' => $receipt->driver->name, ] : null, 'items' => is_string($receipt->items) ? json_decode($receipt->items, true) : $receipt->items ?? [], 'inbound_type' => $receipt->inbound_type, 'client_store' => $receipt->client_store, 'total_items' => $receipt->total_items, 'last_status' => $receipt->last_status, 'status_history' => is_string($receipt->status_history) ? json_decode($receipt->status_history, true) : $receipt->status_history ?? [], ]; }), ]); } public function create() { $drivers = Driver::all(); return inertia('SortingInbound/Form', [ 'drivers' => $drivers, ]); } - MSAnswered
Hello,
Please pay attention to route name
Route::get('/sorting-inbound', [SortingWarehouseReceiptController::class, 'index'])->name('sortinginbound.index'); Route::get('/sorting-inbound/create', [SortingWarehouseReceiptController::class, 'create'])->name('sortinginbound.create');
The permissions should be
read-sortinginbound
andcreate-sortinginbound
. The second part is the route namesortinginbound
Thank you
- NAnswered
Hello @Mian Saleem , Thank you so much. Finally it is working now.
- Login to Reply