<?php namespace BookStack\Repos;
-
-use BookStack\Page;
use BookStack\Role;
-use BookStack\Services\EntityService;
use BookStack\User;
use Setting;
protected $user;
protected $role;
- protected $entityService;
+ protected $entityRepo;
/**
* UserRepo constructor.
* @param User $user
* @param Role $role
- * @param EntityService $entityService
+ * @param EntityRepo $entityRepo
*/
- public function __construct(User $user, Role $role, EntityService $entityService)
+ public function __construct(User $user, Role $role, EntityRepo $entityRepo)
{
$this->user = $user;
$this->role = $role;
- $this->entityService = $entityService;
+ $this->entityRepo = $entityRepo;
}
/**
}
/**
- * Get the pages the the given user has created.
+ * Get the recently created content for this given user.
* @param User $user
* @param int $count
- * @param int $page
* @return mixed
*/
- public function getCreatedPages(User $user, $count = 20, $page = 0)
+ public function getRecentlyCreated(User $user, $count = 20)
{
- return $this->entityService->page->where('created_by', '=', $user->id)->orderBy('created_at', 'desc')
- ->skip($page * $count)->take($count)->get();
+ return [
+ 'pages' => $this->entityRepo->page->where('created_by', '=', $user->id)->orderBy('created_at', 'desc')
+ ->take($count)->get(),
+ 'chapters' => $this->entityRepo->chapter->where('created_by', '=', $user->id)->orderBy('created_at', 'desc')
+ ->take($count)->get(),
+ 'books' => $this->entityRepo->book->where('created_by', '=', $user->id)->orderBy('created_at', 'desc')
+ ->take($count)->get()
+ ];
}
/**
* Get asset created counts for the give user.
+ * @param User $user
* @return array
*/
public function getAssetCounts(User $user)
{
return [
- 'pages' => $this->entityService->page->where('created_by', '=', $user->id)->count(),
- 'chapters' => $this->entityService->chapter->where('created_by', '=', $user->id)->count(),
- 'books' => $this->entityService->book->where('created_by', '=', $user->id)->count(),
+ '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(),
];
}
+
}
\ No newline at end of file