0

I am getting the error: (I searched for this error and saw nothing comparable)

Notice: Undefined property: stdClass::$permissions in

For this line of code: $permissions = json_decode($group->first()->permissions, true);

It is from this:

public function hasPermission($key) {
        $group = $this->_db->get('groups', array('id', '=', $this->data()->group));

        if($group->count()) {
            $permissions = json_decode($group->first()->permissions, true);

            if($permissions[$key] == true) {
                return true;
            }
        }
        return false;
    }

I call for it like so:

if($user->hasPermission('User')) {
    include 'navUser.php';
}

I am unsure what I am doing wrong. This is from a framework and it works on my other sites, the only difference from this site is the folder I am trying to call it from is within a sub-folder, which the other sites the pages were within the root.

What am I doing wrong?

Becky
  • 2,283
  • 2
  • 23
  • 50
  • 1
    The answer would depend on what `$group` has as it's value. My guess would be that `$this->_db->get('groups'....etc...);` is returning no rows and so the call to `$group->first()` is returning an empty object, one without a `permissions` property. – Jonathan Kuhn Oct 18 '16 at 22:10
  • I get bool(false) when I var_dump this: `var_dump($user->hasPermission("User"));` – Becky Oct 18 '16 at 22:11
  • @RiggsFolly How is this a duplicate? I have a specific issue that I cannot figure out?? – Becky Oct 18 '16 at 22:14

0 Answers0