mutual friends
This commit is contained in:
parent
54ff0725a6
commit
6ac7b5fbf0
|
|
@ -47,12 +47,12 @@ class PageController extends Controller
|
|||
public function profile_friends($id)
|
||||
{
|
||||
$user = User::find($id);
|
||||
$friends = $user->getFriends($perPage = 10);
|
||||
|
||||
if (!$user) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$friends = $user->getFriends($perPage = 10);
|
||||
|
||||
$data = [
|
||||
'user' => $user,
|
||||
'friends' => $friends
|
||||
|
|
@ -61,6 +61,23 @@ class PageController extends Controller
|
|||
return view('pages.profile_friends')->with('data', $data);
|
||||
}
|
||||
|
||||
public function mutual_friends($id)
|
||||
{
|
||||
$user = User::find($id);
|
||||
if (!$user || $user->id == Auth::id()) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$friends = Auth::user()->getMutualFriends($user, $perPage = 10);
|
||||
|
||||
$data = [
|
||||
'user' => $user,
|
||||
'friends' => $friends
|
||||
];
|
||||
|
||||
return view('pages.mutual_friends')->with('data', $data);
|
||||
}
|
||||
|
||||
public function users(Request $request)
|
||||
{
|
||||
if ($request->has('q')) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,51 @@
|
|||
@extends('layouts.app')
|
||||
@section('title')
|
||||
<title>{{ $data['user']->name }}'s Friends (Mutual) - {{ env('APP_NAME') }}</title>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<h1 id="usernameframe">Your Mutual Friends with {{ $data['user']->name }} ({{ Auth::user()->getMutualFriendsCount($data['user']) }})</h1>
|
||||
<a href="{{ route('profile_friends', $data['user']->id) }}" class="tab">All Friends</a>
|
||||
@auth
|
||||
<a href="#" class="tab_selected">Mutual Friends ({{ Auth::user()->getMutualFriendsCount($data['user']) }})</a>
|
||||
@endauth
|
||||
<br>
|
||||
<br>
|
||||
<div class="content_special" id="FriendsContainer" style="flex-wrap: wrap;">
|
||||
@foreach ($data['friends'] as $friend)
|
||||
<div class="FriendsContainerBox" id="FriendsContainerBox1">
|
||||
<div id="FriendsContainerBox1ImageContainer">
|
||||
<a href="{{ route('profile', $friend->id) }}"><img alt="Profile Image"
|
||||
src="{{ asset('img/defaultrender.png') }}" width="60px" height="100%"></a>
|
||||
</div>
|
||||
<div id="FriendsContainerBox1TextContainer">
|
||||
<a href="{{ route('profile', $friend->id) }}" id="FeedContainerBox1Username">{{ $friend->name }}</a>
|
||||
@if (!empty($friend->feedposts->last()->status))
|
||||
<p>"{{ $friend->feedposts->last()->status }}"</p>
|
||||
@else
|
||||
<p>"I'm new to ARCHBLOX!"</p>
|
||||
@endif
|
||||
@if (Cache::has('is_online_' . $friend->id))
|
||||
<strong id="onlinestatus" class="onlinestatus_website">Website</strong>
|
||||
@else
|
||||
<strong id="onlinestatus" class="onlinestatus_offline">Offline - Last Online
|
||||
{{ Carbon\Carbon::parse($friend->last_seen)->diffForHumans() }}</strong>
|
||||
@endif
|
||||
<br>
|
||||
@if (Auth::id() == $data['user']->id)
|
||||
<form action="{{ route('friend_remove', $friend->id) }}" method="POST"
|
||||
style="display:inline-block">
|
||||
@csrf
|
||||
<button class="redbutton" type="submit">Unfriend</button>
|
||||
</form>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
@if (!Auth::user()->getMutualFriendsCount($data['user']))
|
||||
<p>You don't have any mutual friends with {{ $data['user']->name }}.</p>
|
||||
@endif
|
||||
{{ $data['friends']->links() }}
|
||||
</div>
|
||||
<br>
|
||||
@endsection
|
||||
|
|
@ -46,7 +46,8 @@
|
|||
<div class="content_special">
|
||||
<div id="profileleftcontainer">
|
||||
@if (!empty($data['user']->feedposts->last()->status))
|
||||
<address id="status" style="word-wrap:break-word">"{{ $data['user']->feedposts->last()->status }}"</address>
|
||||
<address id="status" style="word-wrap:break-word">"{{ $data['user']->feedposts->last()->status }}"
|
||||
</address>
|
||||
@else
|
||||
<address id="status">"I'm new to ARCHBLOX!"</address>
|
||||
@endif
|
||||
|
|
@ -91,6 +92,9 @@
|
|||
<a href="{{ route('profile_friends', $data['user']->id) }}" style="margin-left: 5px"> <button
|
||||
class="bluebutton" style="margin-top: 5px">View All</button></a>
|
||||
</div>
|
||||
@if (Auth::check() && Auth::id() != $data['user']->id && Auth::user()->getMutualFriendsCount($data['user']) > 0)
|
||||
<a href="{{ route('mutual_friends', $data['user']->id) }}" style="color:blue;font-size:12px">{{ Auth::user()->getMutualFriendsCount($data['user'])}} Mutual Friends</a>
|
||||
@endif
|
||||
<div id="profilefriendcontainer" class="content_special"
|
||||
style="flex-wrap: wrap;justify-content: space-evenly;flex-direction: row;display: inline-flex;align-content: center;align-items: center;">
|
||||
@foreach ($data['friends'] as $friend)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,13 @@
|
|||
|
||||
@section('content')
|
||||
<h1 id="usernameframe">{{ $data['user']->name }}'s Friends ({{ $data['user']->getFriendsCount() }})</h1>
|
||||
<a href="#" class="tab_selected">All Friends</a>
|
||||
@auth
|
||||
@if ($data['user']->id != Auth::id())
|
||||
<a href="{{ route('mutual_friends', $data['user']->id) }}" class="tab">Mutual Friends ({{ Auth::user()->getMutualFriendsCount($data['user']) }})</a>
|
||||
@endif
|
||||
@endauth
|
||||
<br>
|
||||
<br>
|
||||
<div class="content_special" id="FriendsContainer" style="flex-wrap: wrap;">
|
||||
@foreach ($data['friends'] as $friend)
|
||||
|
|
@ -38,7 +45,7 @@
|
|||
</div>
|
||||
@endforeach
|
||||
@if (!$data['user']->getFriendsCount())
|
||||
<p>You haven't made friends with anyone yet.</p>
|
||||
<p>{{ $data['user']->name }} hasn't made friends with anyone yet.</p>
|
||||
@endif
|
||||
{{ $data['friends']->links() }}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ Route::middleware(['auth'])->group(function () {
|
|||
Route::post('/home', [App\Http\Controllers\HomeController::class, 'feed_post'])->name('feed_post');
|
||||
});
|
||||
|
||||
Route::get('/user/{id}/friends/mutual', [App\Http\Controllers\PageController::class, 'mutual_friends'])->name('mutual_friends');
|
||||
Route::get('/users', [App\Http\Controllers\PageController::class, 'users'])->name('users');
|
||||
Route::post('/users', [App\Http\Controllers\PageController::class, 'users'])->name('users');
|
||||
Route::get('/my/settings', [App\Http\Controllers\PageController::class, 'settings'])->name('settings');
|
||||
|
|
|
|||
Loading…
Reference in New Issue