Cache user permissions between calls

This commit is contained in:
Toby Zerner 2015-06-16 17:18:02 +09:30
parent f6e6090131
commit 822feb2497

View File

@ -311,9 +311,13 @@ class User extends Model
return true; return true;
} }
$count = $this->permissions()->where('permission', $permission)->count(); static $permissions;
return (bool) $count; if (!$permissions) {
$permissions = $this->permissions()->get();
}
return (bool) $permissions->contains('permission', $permission);
} }
public function getUnreadNotificationsCount() public function getUnreadNotificationsCount()