+
+ /**
+ * Remove the given user from storage, Delete all related content.
+ * @param User $user
+ */
+ public function destroy(User $user)
+ {
+ $user->socialAccounts()->delete();
+ $user->delete();
+ }
+
+ /**
+ * Get the latest activity for a user.
+ * @param User $user
+ * @param int $count
+ * @param int $page
+ * @return array
+ */
+ public function getActivity(User $user, $count = 20, $page = 0)
+ {
+ return \Activity::userActivity($user, $count, $page);
+ }
+
+ /**
+ * Get the recently created content for this given user.
+ * @param User $user
+ * @param int $count
+ * @return mixed
+ */
+ public function getRecentlyCreated(User $user, $count = 20)
+ {
+ return [
+ 'pages' => $this->entityRepo->getRecentlyCreated('page', $count, 0, function ($query) use ($user) {
+ $query->where('created_by', '=', $user->id);
+ }),
+ 'chapters' => $this->entityRepo->getRecentlyCreated('chapter', $count, 0, function ($query) use ($user) {
+ $query->where('created_by', '=', $user->id);
+ }),
+ 'books' => $this->entityRepo->getRecentlyCreated('book', $count, 0, function ($query) use ($user) {
+ $query->where('created_by', '=', $user->id);
+ })
+ ];
+ }
+
+ /**
+ * Get asset created counts for the give user.
+ * @param User $user
+ * @return array
+ */
+ public function getAssetCounts(User $user)
+ {
+ return [
+ 'pages' => $this->entityRepo->page->where('created_by', '=', $user->id)->count(),
+ 'chapters' => $this->entityRepo->chapter->where('created_by', '=', $user->id)->count(),
+ 'books' => $this->entityRepo->book->where('created_by', '=', $user->id)->count(),
+ ];
+ }
+
+ /**
+ * Get the roles in the system that are assignable to a user.
+ * @return mixed
+ */
+ public function getAllRoles()
+ {
+ return $this->role->all();
+ }
+
+ /**
+ * Get all the roles which can be given restricted access to
+ * other entities in the system.
+ * @return mixed
+ */
+ public function getRestrictableRoles()
+ {
+ return $this->role->where('system_name', '!=', 'admin')->get();
+ }
+