Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions app/Http/Controllers/Personal/Comment/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@

use App\Http\Controllers\Controller;
use Illuminate\Contracts\View\Factory as ViewFactory;
use Illuminate\Contracts\Auth\Authenticatable;

class IndexController extends Controller
{
public function __invoke(ViewFactory $view_factory)
public function __invoke(ViewFactory $view_factory, Authenticatable $user)
{
/** @phpstan-ignore-next-line */
$comments = auth()->user()->comments;
$comments = $user->comments;

return $view_factory->make('personal.comment.index', ['comments' => $comments]);
}
Expand Down
5 changes: 3 additions & 2 deletions app/Http/Controllers/Personal/Liked/DeleteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@

use App\Http\Controllers\Controller;
use App\Models\Post;
use Illuminate\Contracts\Auth\Authenticatable;

class DeleteController extends Controller
{
public function __invoke(Post $post)
public function __invoke(Post $post, Authenticatable $user)
{
/** @phpstan-ignore-next-line */
auth()->user()->likedPosts()->detach($post->id);
$user->likedPosts()->detach($post->id);

return redirect()->route('personal.liked.index');
}
Expand Down
5 changes: 3 additions & 2 deletions app/Http/Controllers/Personal/Liked/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
namespace App\Http\Controllers\Personal\Liked;

use App\Http\Controllers\Controller;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Contracts\View\Factory as ViewFactory;

class IndexController extends Controller
{
public function __invoke(ViewFactory $view_factory)
public function __invoke(ViewFactory $view_factory, Authenticatable $user)
{
/** @phpstan-ignore-next-line */
$posts = auth()->user()->likedPosts;
$posts = $user->likedPosts;

return $view_factory->make('personal.liked.index', ['posts' => $posts]);
}
Expand Down
7 changes: 4 additions & 3 deletions app/Http/Controllers/Personal/Main/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
namespace App\Http\Controllers\Personal\Main;

use App\Http\Controllers\Controller;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Contracts\View\Factory as ViewFactory;

class IndexController extends Controller
{
public function __invoke(ViewFactory $view_factory)
public function __invoke(ViewFactory $view_factory, Authenticatable $user)
{
/** @phpstan-ignore-next-line */
$data['countComments'] = count(auth()->user()->comments);
$data['countComments'] = count($user->comments);
/** @phpstan-ignore-next-line */
$data['countLiked'] = count(auth()->user()->likedPosts);
$data['countLiked'] = count($user->likedPosts);

return $view_factory->make('personal.main.index', ['data' => $data]);
}
Expand Down
9 changes: 5 additions & 4 deletions app/Http/Controllers/Post/Comment/StoreController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@
use App\Http\Requests\Post\Comment\StoreRequest;
use App\Models\Comment;
use App\Models\Post;
use Illuminate\Contracts\Auth\Authenticatable;

class StoreController extends Controller
{
public function __invoke(StoreRequest $request, Post $post)
public function __invoke(StoreRequest $request, Post $post, Authenticatable $user)
{
$data = $request->validated();
$data = $request->validated();
$data['post_id'] = $post->id;
/** @phpstan-ignore-next-line */
$data['user_id'] = auth()->user()->id;
/** @phpstan-ignore-next-line */
$data['user_id'] = $user->id;
/** @phpstan-ignore-next-line */
Comment::create($data);

Expand Down
5 changes: 3 additions & 2 deletions app/Http/Controllers/Post/Like/StoreController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@

use App\Http\Controllers\Controller;
use App\Models\Post;
use Illuminate\Contracts\Auth\Authenticatable;

class StoreController extends Controller
{
public function __invoke(Post $post)
public function __invoke(Post $post, Authenticatable $user)
{
/** @phpstan-ignore-next-line */
auth()->user()->likedPosts()->toggle($post->id);
$user->likedPosts()->toggle($post->id);

return redirect()->back();
}
Expand Down
5 changes: 3 additions & 2 deletions app/Http/Middleware/AdminMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Http\Middleware;

use Closure;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;

Expand All @@ -13,10 +14,10 @@ class AdminMiddleware
*
* @param Closure(Request): (Response) $next
*/
public function handle(Request $request, Closure $next): Response
public function handle(Request $request, Closure $next, Authenticatable $user): Response
{
/** @phpstan-ignore-next-line */
if (auth()->user()->isReader()) {
if ($user->isReader()) {
abort(404);
}

Expand Down