-
-
Notifications
You must be signed in to change notification settings - Fork 668
Add Block users feature #879
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
46643f6
add blocked users table
sawirricardo 8037b4d
add blockedUser relationship
sawirricardo 46277b6
add crud to blocked users list
sawirricardo 8481c9d
add crud component to the settings page
sawirricardo 8cce3f3
add scopes
sawirricardo 862d4f4
fix styleci check
sawirricardo 087fbf3
format code
sawirricardo 407e761
reformat code
sawirricardo bdd42c0
reformat code
sawirricardo bf8b76e
add avatar
sawirricardo ebfc860
wip
driesvints 94af4cb
wip
driesvints 2a6dbb7
wip
driesvints 4081a7f
wip
driesvints File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,28 @@ | ||
| <?php | ||
|
|
||
| namespace App\Http\Controllers; | ||
|
|
||
| use App\Jobs\BlockUser; | ||
| use App\Models\User; | ||
| use App\Policies\UserPolicy; | ||
| use Illuminate\Auth\Middleware\Authenticate; | ||
| use Illuminate\Http\Request; | ||
|
|
||
| class BlockUserController extends Controller | ||
| { | ||
| public function __construct() | ||
| { | ||
| $this->middleware(Authenticate::class); | ||
| } | ||
|
|
||
| public function __invoke(Request $request, User $user) | ||
| { | ||
| $this->authorize(UserPolicy::BLOCK, $user); | ||
|
|
||
| $this->dispatchSync(new BlockUser($request->user(), $user)); | ||
|
|
||
| $this->success('settings.user.blocked'); | ||
|
|
||
| return redirect()->route('profile', $user->username()); | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,29 @@ | ||
| <?php | ||
|
|
||
| namespace App\Http\Controllers\Settings; | ||
|
|
||
| use App\Http\Controllers\Controller; | ||
| use App\Jobs\UnblockUser; | ||
| use App\Models\User; | ||
| use App\Policies\UserPolicy; | ||
| use Illuminate\Auth\Middleware\Authenticate; | ||
| use Illuminate\Http\Request; | ||
|
|
||
| class UnblockUserController extends Controller | ||
| { | ||
| public function __construct() | ||
| { | ||
| $this->middleware(Authenticate::class); | ||
| } | ||
|
|
||
| public function __invoke(Request $request, User $user) | ||
| { | ||
| $this->authorize(UserPolicy::BLOCK, $user); | ||
|
|
||
| $this->dispatchSync(new UnblockUser($request->user(), $user)); | ||
|
|
||
| $this->success('settings.user.unblocked'); | ||
|
|
||
| return redirect()->route('settings.profile'); | ||
| } | ||
| } |
This file contains hidden or 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,28 @@ | ||
| <?php | ||
|
|
||
| namespace App\Http\Controllers; | ||
|
|
||
| use App\Jobs\UnblockUser; | ||
| use App\Models\User; | ||
| use App\Policies\UserPolicy; | ||
| use Illuminate\Auth\Middleware\Authenticate; | ||
| use Illuminate\Http\Request; | ||
|
|
||
| class UnblockUserController extends Controller | ||
| { | ||
| public function __construct() | ||
| { | ||
| $this->middleware(Authenticate::class); | ||
| } | ||
|
|
||
| public function __invoke(Request $request, User $user) | ||
| { | ||
| $this->authorize(UserPolicy::BLOCK, $user); | ||
|
|
||
| $this->dispatchSync(new UnblockUser($request->user(), $user)); | ||
|
|
||
| $this->success('settings.user.unblocked'); | ||
|
|
||
| return redirect()->route('profile', $user->username()); | ||
| } | ||
| } |
This file contains hidden or 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,17 @@ | ||
| <?php | ||
|
|
||
| namespace App\Jobs; | ||
|
|
||
| use App\Models\User; | ||
|
|
||
| final class BlockUser | ||
| { | ||
| public function __construct(private User $user, private User $blockedUser) | ||
| { | ||
| } | ||
|
|
||
| public function handle(): void | ||
| { | ||
| $this->user->blockedUsers()->attach($this->blockedUser); | ||
| } | ||
| } |
This file contains hidden or 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,17 @@ | ||
| <?php | ||
|
|
||
| namespace App\Jobs; | ||
|
|
||
| use App\Models\User; | ||
|
|
||
| final class UnblockUser | ||
| { | ||
| public function __construct(private User $user, private User $blockedUser) | ||
| { | ||
| } | ||
|
|
||
| public function handle(): void | ||
| { | ||
| $this->user->blockedUsers()->detach($this->blockedUser); | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
19 changes: 19 additions & 0 deletions
19
database/migrations/2022_06_14_072001_create_blocked_users_table.php
This file contains hidden or 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,19 @@ | ||
| <?php | ||
|
|
||
| use Illuminate\Database\Migrations\Migration; | ||
| use Illuminate\Database\Schema\Blueprint; | ||
| use Illuminate\Support\Facades\Schema; | ||
|
|
||
| return new class extends Migration | ||
| { | ||
| public function up() | ||
| { | ||
| Schema::create('blocked_users', function (Blueprint $table) { | ||
| $table->id(); | ||
| $table->unsignedInteger('user_id'); | ||
| $table->foreign('user_id')->references('id')->on('users')->cascadeOnDelete(); | ||
| $table->unsignedInteger('blocked_user_id'); | ||
| $table->foreign('blocked_user_id')->references('id')->on('users')->cascadeOnDelete(); | ||
| }); | ||
| } | ||
| }; |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.