diff --git a/app/Hashtag.php b/app/Hashtag.php index 29c4ca9b..1e3ced6f 100644 --- a/app/Hashtag.php +++ b/app/Hashtag.php @@ -20,8 +20,8 @@ class Hashtag extends Model ); } - public function url() + public function url($suffix = '') { - return config('routes.hashtag.base').$this->slug; + return config('routes.hashtag.base').$this->slug.$suffix; } } diff --git a/app/Http/Controllers/Settings/RelationshipSettings.php b/app/Http/Controllers/Settings/RelationshipSettings.php index efc369fe..a2f1cfea 100644 --- a/app/Http/Controllers/Settings/RelationshipSettings.php +++ b/app/Http/Controllers/Settings/RelationshipSettings.php @@ -18,15 +18,29 @@ trait RelationshipSettings public function relationshipsHome(Request $request) { - $mode = $request->input('mode') == 'following' ? 'following' : 'followers'; + $this->validate($request, [ + 'mode' => 'nullable|string|in:following,followers,hashtags' + ]); + + $mode = $request->input('mode'); $profile = Auth::user()->profile; - $following = $followers = []; + switch ($mode) { + case 'following': + $data = $profile->following()->simplePaginate(10); + break; - if($mode == 'following') { - $data = $profile->following()->simplePaginate(10); - } else { - $data = $profile->followers()->simplePaginate(10); + case 'followers': + $data = $profile->followers()->simplePaginate(10); + break; + + case 'hashtags': + $data = $profile->hashtagFollowing()->with('hashtag')->simplePaginate(10); + break; + + default: + $data = []; + break; } return view('settings.relationships.home', compact('profile', 'mode', 'data')); diff --git a/app/Profile.php b/app/Profile.php index aec219cc..0737f997 100644 --- a/app/Profile.php +++ b/app/Profile.php @@ -278,4 +278,9 @@ class Profile extends Model 'hashtag_id' ); } + + public function hashtagFollowing() + { + return $this->hasMany(HashtagFollow::class); + } } diff --git a/resources/views/settings/partial/sidebar.blade.php b/resources/views/settings/partial/sidebar.blade.php index 32f4ff6c..5606a2b7 100644 --- a/resources/views/settings/partial/sidebar.blade.php +++ b/resources/views/settings/partial/sidebar.blade.php @@ -9,9 +9,6 @@
You are not {{$mode == 'following' ? 'following anyone.' : 'followed by anyone.'}}
-@elseYou are not {{$mode == 'hashtags' ? 'following any hashtags.' : ($mode == 'following' ? 'following anyone.' : 'followed by anyone.')}}
+@else+ + | --}} +Hashtag | +Action | +
---|---|---|
+
+ #{{$hashtag->hashtag->name}} + + |
+ + Unfollow + | +|
@@ -52,6 +79,7 @@ @endif |