Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Fixes #42 Add breadcrumbs to User Profiles #99

Merged
merged 2 commits into from
Apr 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace MyBB\Core\Http\Controllers;

use DaveJamesMiller\Breadcrumbs\Manager as Breadcrumbs;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we just create a sub-class of this called Breadcrumbs and save ourselves having to alias everywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably. But there are also some other classes we alias everywhere (all Manager and Repository classes). If we change that we should change it everywhere.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, we don't have to do it all in one go though!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's always better to do it in one go ;) Otherwise we start missing things again etc.

use MyBB\Core\Database\Repositories\UserRepositoryInterface;
use MyBB\Core\Database\Repositories\ProfileFieldGroupRepositoryInterface;
use MyBB\Core\Database\Repositories\UserProfileFieldRepositoryInterface;
Expand Down Expand Up @@ -34,14 +35,21 @@ public function __construct(
* @param string $slug
* @param int $id
* @param ProfileFieldGroupRepositoryInterface $profileFieldGroups
* @param Breadcrumbs $breadcrumbs
*
* @return \Illuminate\View\View
*/
public function profile($slug, $id, ProfileFieldGroupRepositoryInterface $profileFieldGroups)
{
public function profile(
$slug,
$id,
ProfileFieldGroupRepositoryInterface $profileFieldGroups,
Breadcrumbs $breadcrumbs
) {
$user = $this->users->find($id);
$groups = $profileFieldGroups->getAll();

$breadcrumbs->setCurrentRoute('user.profile', $user);

return view('user.profile', [
'user' => $user,
'profile_field_groups' => $groups
Expand Down
8 changes: 8 additions & 0 deletions app/Http/breadcrumbs.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,11 @@
route('search.results', ['id' => $searchlog->id])
);
});

Breadcrumbs::register('user.profile', function ($breadcrumbs, $user) {
$breadcrumbs->parent('forum.index');
$breadcrumbs->push(
trans('member.profileOf', ['name' => $user->name]),
route('user.profile', ['slug' => $user->name, 'id' => $user->id])
);
});
1 change: 1 addition & 0 deletions resources/lang/en/member.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
'lastVisit' => 'Last Visit',
'online' => 'Online Now',
'noOnline' => 'Nobody is online',
'profileOf' => 'Profile of :name',

'profile' => [
'recentActivity' => 'Recent Activity',
Expand Down