-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Added possibility to remove followers (#219)
* Added possibility to remove followers * Adde translation * Added link to profile * Show user- and displayname * Added translation * Improved UI when user have no followers
- Loading branch information
1 parent
e5e66cf
commit b2e78d3
Showing
12 changed files
with
266 additions
and
45 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Models\Follow; | ||
use Illuminate\Contracts\Support\Renderable; | ||
use Illuminate\Http\RedirectResponse; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Validation\Rule; | ||
|
||
class SettingsController extends Controller | ||
{ | ||
public function renderFollowerSettings(): Renderable { | ||
return view('settings.follower', [ | ||
'followers' => auth()->user()->followers()->paginate(15) | ||
]); | ||
} | ||
|
||
public function removeFollower(Request $request): RedirectResponse { | ||
$validated = $request->validate([ | ||
'user_id' => ['required', Rule::in(auth()->user()->followers->pluck('id'))] | ||
]); | ||
|
||
$follow = Follow::where('user_id', $validated['user_id']) | ||
->where('follow_id', auth()->user()->id) | ||
->firstOrFail(); | ||
|
||
$this->authorize('delete', $follow); | ||
$follow->delete(); | ||
|
||
return back()->with('success', __('settings.follower.delete-success')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
|
||
namespace App\Policies; | ||
|
||
use App\Models\Follow; | ||
use App\Models\User; | ||
use Illuminate\Auth\Access\HandlesAuthorization; | ||
|
||
class FollowPolicy | ||
{ | ||
use HandlesAuthorization; | ||
|
||
/** | ||
* Determine whether the user can view any models. | ||
* | ||
* @param User $user | ||
* @return mixed | ||
*/ | ||
public function viewAny(User $user) { | ||
// | ||
} | ||
|
||
/** | ||
* Determine whether the user can view the model. | ||
* | ||
* @param User $user | ||
* @param Follow $follow | ||
* @return mixed | ||
*/ | ||
public function view(User $user, Follow $follow) { | ||
// | ||
} | ||
|
||
/** | ||
* Determine whether the user can create models. | ||
* | ||
* @param User $user | ||
* @return mixed | ||
*/ | ||
public function create(User $user) { | ||
// | ||
} | ||
|
||
/** | ||
* Determine whether the user can update the model. | ||
* | ||
* @param User $user | ||
* @param Follow $follow | ||
* @return mixed | ||
*/ | ||
public function update(User $user, Follow $follow) { | ||
// | ||
} | ||
|
||
/** | ||
* Determine whether the user can delete the model. | ||
* | ||
* @param User $user | ||
* @param Follow $follow | ||
* @return mixed | ||
*/ | ||
public function delete(User $user, Follow $follow): bool { | ||
return $user->id == $follow->follow_id; | ||
} | ||
|
||
/** | ||
* Determine whether the user can restore the model. | ||
* | ||
* @param User $user | ||
* @param Follow $follow | ||
* @return mixed | ||
*/ | ||
public function restore(User $user, Follow $follow) { | ||
// | ||
} | ||
|
||
/** | ||
* Determine whether the user can permanently delete the model. | ||
* | ||
* @param User $user | ||
* @param Follow $follow | ||
* @return mixed | ||
*/ | ||
public function forceDelete(User $user, Follow $follow) { | ||
// | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,25 @@ | ||
<?php | ||
return [ | ||
"abort" => "Abbrechen", | ||
"about" => "Über Träwelling", | ||
"active" => "Unterwegs", | ||
"blog" => "Blog", | ||
"dashboard" => "Dashboard", | ||
"developed" => "Entwickelt mit <i class=\"fas fa-heart fa-sm\" style=\"color: Tomato;\"\"></i> in der Europäischen Union. <a href='https://github.com/traewelling/traewelling'>Quellcode</a> lizensiert unter <a href='https://www.gnu.org/licenses/agpl-3.0.html'>AGPLv3</a>.", | ||
"discard" => "Abbrechen", | ||
"export" => "Exportieren", | ||
"globaldashboard" => "Globales Dashboard", | ||
"gohome" => "Zur Startseite", | ||
"imprint" => "Impressum", | ||
"leaderboard" => "Top-Träweller", | ||
"login" => "Anmelden", | ||
"logout" => "Abmelden", | ||
"ohno" => "Oh nein!", | ||
"privacy" => "Datenschutz", | ||
"profile" => "Profil", | ||
"register" => "Registrieren", | ||
"settings" => "Einstellungen", | ||
"admin" => "Admin-Panel", | ||
"readmore" => "Mehr lesen" | ||
"abort" => "Abbrechen", | ||
"about" => "Über Träwelling", | ||
"active" => "Unterwegs", | ||
"blog" => "Blog", | ||
"dashboard" => "Dashboard", | ||
"developed" => "Entwickelt mit <i class=\"fas fa-heart fa-sm\" style=\"color: Tomato;\"\"></i> in der Europäischen Union. <a href='https://github.com/traewelling/traewelling'>Quellcode</a> lizensiert unter <a href='https://www.gnu.org/licenses/agpl-3.0.html'>AGPLv3</a>.", | ||
"discard" => "Abbrechen", | ||
"export" => "Exportieren", | ||
"globaldashboard" => "Globales Dashboard", | ||
"gohome" => "Zur Startseite", | ||
"imprint" => "Impressum", | ||
"leaderboard" => "Top-Träweller", | ||
"login" => "Anmelden", | ||
"logout" => "Abmelden", | ||
"ohno" => "Oh nein!", | ||
"privacy" => "Datenschutz", | ||
"profile" => "Profil", | ||
"register" => "Registrieren", | ||
"settings" => "Einstellungen", | ||
"settings-myFollower" => "Meine Follower", | ||
"admin" => "Admin-Panel", | ||
"readmore" => "Mehr lesen" | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,25 @@ | ||
<?php | ||
return [ | ||
"abort" => "Abort", | ||
"about" => "About", | ||
"active" => "En Route", | ||
"blog" => "Blog", | ||
"dashboard" => "Dashboard", | ||
"developed" => "Developed with <i class=\"fas fa-heart fa-sm\" style=\"color: Tomato;\"\"></i> in the European Union. <a href='https://github.com/traewelling/traewelling'>Source code</a> licensed under <a href='https://www.gnu.org/licenses/agpl-3.0.html'>AGPLv3</a>.", | ||
"discard" => "Discard", | ||
"export" => "Export", | ||
"globaldashboard" => "Global Dashboard", | ||
"gohome" => "Go Home", | ||
"imprint" => "Imprint", | ||
"leaderboard" => "Leaderboard", | ||
"login" => "Login", | ||
"logout" => "Logout", | ||
"ohno" => "Oh no", | ||
"privacy" => "Privacy", | ||
"profile" => "Profile", | ||
"register" => "Register", | ||
"settings" => "Settings", | ||
"admin" => "Admin-Panel", | ||
"readmore" => "Read more" | ||
"abort" => "Abort", | ||
"about" => "About", | ||
"active" => "En Route", | ||
"blog" => "Blog", | ||
"dashboard" => "Dashboard", | ||
"developed" => "Developed with <i class=\"fas fa-heart fa-sm\" style=\"color: Tomato;\"\"></i> in the European Union. <a href='https://github.com/traewelling/traewelling'>Source code</a> licensed under <a href='https://www.gnu.org/licenses/agpl-3.0.html'>AGPLv3</a>.", | ||
"discard" => "Discard", | ||
"export" => "Export", | ||
"globaldashboard" => "Global Dashboard", | ||
"gohome" => "Go Home", | ||
"imprint" => "Imprint", | ||
"leaderboard" => "Leaderboard", | ||
"login" => "Login", | ||
"logout" => "Logout", | ||
"ohno" => "Oh no", | ||
"privacy" => "Privacy", | ||
"profile" => "Profile", | ||
"register" => "Register", | ||
"settings" => "Settings", | ||
"settings-myFollower" => "My followers", | ||
"admin" => "Admin-Panel", | ||
"readmore" => "Read more" | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
@extends('layouts.app') | ||
|
||
@section('title') {{ __('menu.settings-myFollower') }} @endsection | ||
|
||
@section('content') | ||
<div class="container"> | ||
<div class="row justify-content-center"> | ||
<div class="col-md-8"> | ||
<div class="card"> | ||
<div class="card-header">{{ __('menu.settings-myFollower') }}</div> | ||
|
||
<div class="card-body"> | ||
|
||
@if($followers->count() == 0) | ||
<b class="text-danger"> | ||
<i class="fas fa-users-slash"></i> | ||
{{__('settings.follower.no-follower')}} | ||
</b> | ||
@else | ||
|
||
<table class="table table-responsive table-striped"> | ||
<thead> | ||
<tr> | ||
<th colspan="2">Follower</th> | ||
<th>{{__('settings.follower.following-since')}}</th> | ||
<th></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@foreach($followers as $follower) | ||
<tr> | ||
<td> | ||
<div class="image-box pr-0 d-none d-lg-flex"> | ||
<a href="{{ route('account.show', ['username' => $follower->username]) }}"> | ||
<img src="{{ route('account.showProfilePicture', ['username' => $follower->username]) }}" | ||
style="height: 3em;" | ||
/> | ||
</a> | ||
</div> | ||
</td> | ||
<td style="vertical-align: middle"> | ||
<a href="{{route('account.show', ['username' => $follower->username])}}"> | ||
{{$follower->name}} | ||
@if($follower->name != $follower->username) | ||
<br/> | ||
<small>{{'@' . $follower->username}}</small> | ||
@endif | ||
</a> | ||
</td> | ||
<td style="vertical-align: middle">{{$follower->created_at->diffForHumans()}}</td> | ||
<td> | ||
<form method="POST" action="{{route('settings.follower.remove')}}"> | ||
@csrf | ||
<input type="hidden" name="user_id" value="{{$follower->id}}"/> | ||
<button type="submit" class="btn btn-sm btn-danger"> | ||
<i class="fas fa-users-slash"></i> | ||
{{__('settings.follower.delete')}} | ||
</button> | ||
</form> | ||
</td> | ||
</tr> | ||
@endforeach | ||
</tbody> | ||
</table> | ||
{{$followers->links()}} | ||
@endif | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
@endsection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters