Add this to your existing app/Models/User.php:

1. Update $fillable to include 'role_id':

   protected $fillable = ['name', 'email', 'password', 'type_id', 'shop_id', 'role_id', 'is_active'];

2. Add these two methods inside the User class (near the existing shop() method):

    public function role()
    {
        return $this->belongsTo(Role::class);
    }

    public function hasPermission(string $key): bool
    {
        // Super Admin (type_id 1) always has access to everything
        if ($this->type_id === 1) {
            return true;
        }

        // Shop Owner (type_id 2) always has full access within their own shop
        if ($this->type_id === 2) {
            return true;
        }

        // Staff (type_id 3) — check their assigned role's permissions
        return $this->role?->hasPermission($key) ?? false;
    }
