now users can be unfollowed

This commit is contained in:
Ghostie 2024-08-23 15:17:08 -05:00
parent 31262f442c
commit 6ab13ff55a
3 changed files with 10 additions and 2 deletions

View File

@ -13,4 +13,11 @@ class FollowerController extends Controller
return back();
}
public function destroy(User $user)
{
$user->followers()->detach(auth()->user()->id);
return back();
}
}

View File

@ -41,6 +41,6 @@ class SignupController extends Controller
// authenticate user
Auth::attempt($request->only("email", "password"));
return redirect()->route("posts.index");
return redirect()->route("posts.index", auth()->user()->username);
}
}

View File

@ -53,8 +53,9 @@
class="bg-blue-600 text-white uppercase rounded-lg px-3 py-1 text-xs font-bold cursor-pointer"
value="follow">
</form>
<form action="#" method="POST">
<form action="{{ route('users.unfollow', $user) }}" method="POST">
@csrf
@method('DELETE')
<input type="submit"
class="bg-red-600 text-white uppercase rounded-lg px-3 py-1 text-xs font-bold cursor-pointer"
value="unfollow">