2021-06-26 23:23:15 +08:00
|
|
|
<?php
|
|
|
|
|
2023-05-18 00:56:55 +08:00
|
|
|
namespace BookStack\Users\Controllers;
|
2021-03-10 07:06:12 +08:00
|
|
|
|
2023-05-18 00:56:55 +08:00
|
|
|
use BookStack\Activity\ActivityQueries;
|
2023-05-19 03:53:39 +08:00
|
|
|
use BookStack\Http\Controller;
|
2023-05-18 00:56:55 +08:00
|
|
|
use BookStack\Users\Queries\UserContentCounts;
|
|
|
|
use BookStack\Users\Queries\UserRecentlyCreatedContent;
|
|
|
|
use BookStack\Users\UserRepo;
|
2021-03-10 07:06:12 +08:00
|
|
|
|
|
|
|
class UserProfileController extends Controller
|
|
|
|
{
|
2024-02-08 00:37:36 +08:00
|
|
|
public function __construct(
|
|
|
|
protected UserRepo $userRepo,
|
|
|
|
protected ActivityQueries $activityQueries,
|
|
|
|
protected UserContentCounts $contentCounts,
|
|
|
|
protected UserRecentlyCreatedContent $recentlyCreatedContent
|
|
|
|
) {
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-10 07:06:12 +08:00
|
|
|
/**
|
2021-06-26 23:23:15 +08:00
|
|
|
* Show the user profile page.
|
2021-03-10 07:06:12 +08:00
|
|
|
*/
|
2024-02-08 00:37:36 +08:00
|
|
|
public function show(string $slug)
|
2021-03-10 07:06:12 +08:00
|
|
|
{
|
2024-02-08 00:37:36 +08:00
|
|
|
$user = $this->userRepo->getBySlug($slug);
|
2021-03-10 07:06:12 +08:00
|
|
|
|
2024-02-08 00:37:36 +08:00
|
|
|
$userActivity = $this->activityQueries->userActivity($user);
|
|
|
|
$recentlyCreated = $this->recentlyCreatedContent->run($user, 5);
|
|
|
|
$assetCounts = $this->contentCounts->run($user);
|
2021-03-10 07:06:12 +08:00
|
|
|
|
2022-01-04 21:33:24 +08:00
|
|
|
$this->setPageTitle($user->name);
|
|
|
|
|
2021-03-10 07:06:12 +08:00
|
|
|
return view('users.profile', [
|
2021-06-26 23:23:15 +08:00
|
|
|
'user' => $user,
|
|
|
|
'activity' => $userActivity,
|
2021-03-10 07:06:12 +08:00
|
|
|
'recentlyCreated' => $recentlyCreated,
|
2021-06-26 23:23:15 +08:00
|
|
|
'assetCounts' => $assetCounts,
|
2021-03-10 07:06:12 +08:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|