Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

Add Restaurant Staff Members

Premium
10 min read

Comments & Discussion

N
Nillos ✓ Link copied!

Hi, if role "Admin", when I hit the "Staff Management" button, I get the message: "Attempt to read property "staff" on null" -> StaffMemberController

J
Joe ✓ Link copied!

The admin user doesn't have a restaurant so using this code it's impossible to add a staff member because there is no available restaurant to associate it with.

For it to be possible to add a staff member from the admin user, we'd need to have a dropdown on the AddStaffMemberForm.vue to choose a restaurant.

DL
David Lun ✓ Link copied!

yeah, admin is not supposed to visit staff management page, we should add check if the user is really admin to fix that, thanks for noticing.

UPDATE: Course is updated, also commenting here if anyone has this issue

Since admin also has user.create permission we add additional check if authenticated user has vendor role. Admin should not be able to manage staff members.

resources/js/Layouts/AuthenticatedLayout.vue

<template>
  <!-- ... -->
        My Orders
      </NavLink>
      <NavLink
        v-if="can('user.create') && $page.props.auth.is_vendor"
        :href="route('vendor.staff-members.index')"
        :active="route().current('vendor.staff-members.index')"
      >
        Staff Management
      </NavLink>
    </div>
  </div>
  <!-- ... -->
</template>

And add is_vendor property to the shared data.

app/Http/Middleware/HandleInertiaRequests.php

'auth' => [
    'user'        => $request->user(),
    'permissions' => $request->user()?->permissions() ?? [],
    'is_vendor'   => $request->user()?->isVendor()
],