Laravel Türkiye Discord Kanalı Forumda kod paylaşılırken dikkat edilmesi gerekenler!Birlikte proje geliştirmek ister misiniz?

Twitter yorum yapısını yapmak istedim başta iyiydi fakat atılan yorumun içine girmek istediğimde hata alıyorum (404).

https://prnt.sc/S1HTx4nVv-CA

buna girdiğimde şöyle bir şey geliyor

https://prnt.sc/SXDaksToWaRT

Atıllan yorumun urlsi şöyle

https://prnt.sc/OgouYBQ3RHrS

Database yapım şöyle
https://prnt.sc/RXZEUmdigCL-

Route

    Route::get('/{user:username}/status/{tweet:id}', [TweetsController::class, 'show'])->name('tweet.show');
<Link :href="tweetLink(comment.user.username, comment.tweet_id)">
                <div class="text-sm text-normalWhite">
                    {{ comment.body }}
                </div>
            </Link>
public function show(User $user,Tweet $tweet, Request $request) {
        $comments = $tweet->comments()->with('user')->latest()->get();
        $tweetStats = [
            'likes_count' => $tweet->likes()->count(),
            'liked' => $tweet->likes()->where('user_id', auth()->id())->exists(),
            'tweet_view_count' => $tweet->tweet_view()->count(),
            'comments_count' => $tweet->comments()->count(),
        ];

        if (!Cookie::has('viewed_posts')) {
            $viewedPosts = [];
        } else {
            $viewedPosts = json_decode(Cookie::get('viewed_posts'), true);
        }
        
        if (!in_array($tweet->id, $viewedPosts)) {
            TweetView::create([
                'ip_address' => $request->ip(),
                'user_agent' => $request->userAgent(),
                'tweet_id' => $tweet->id,
                'user_id' => $request->user()?->id,
            ]);
        
            $viewedPosts[] = $tweet->id;
        
            Cookie::queue('viewed_posts', json_encode($viewedPosts), 60 * 24 * 365);
        }
    
        return Inertia::render('detail', [
            'tweet' => $tweet->load('user'),
            'tweetStats' => $tweetStats,
            'comments' => $comments,
        ]);
    }
class Comment extends Model
{
    use HasFactory;

    protected $guarded = [];

    public function tweet() {
        return $this->belongsTo(Tweet::class);
    }

    public function user() {
        return $this->belongsTo(User::class, 'user_id');
    }
}

Tweet

public function comments(): HasMany
    {
        return $this->hasMany(Comment::class);
    }

Bence twitter id alıyor fakat ben yorumu comments de body içinde tutuyorum o yüzden sorun oluyor. Peki bunu farklı nasıl yapabilirdim.

    12 gün sonra

    aghabalaguluzade @mgsmus hocam bu işin içinden çıkamadım

        Route::post('/tweets/{tweet:id}/reply', [TweetCommentsController::class, 'reply'])->name('reply');
    public function reply(Request $request) {
    
            try {
                $request->validate([
                    'tweet_id' => ['required'],
                    'body' => ['required','max:280'],
                    'mediaIds.*' => [
                        Rule::exists('media', 'id')
                            ->where(function($q) use ($request) {
                                return $q->where('user_id', $request->user()->id);
                        })
                    ],
                ]);
        
                $comment = Comment::create([
                    'user_id' => auth()->id(),
                    'tweet_id' => $request->input('tweet_id'),
                    'body' => $request->input('body'),  
                ]);
        
                Media::find($request->input('mediaIds'))->each->update([
                    'model_id' => $comment->id,
                    'model_type' => Tweet::class,
                ]);
        
                return redirect()->back();
            } catch (\Throwable $th) {
                return false;
            }
    
        }

    kanaatimce comments

    Schema::create('comments', function (Blueprint $table) {
                $table->id();
                $table->foreignId('user_id')->constrained()->cascadeOnDelete();
                $table->foreignId('tweet_id')->constrained()->cascadeOnDelete();
                $table->timestamps();
            });

    şöyle olacak commenti twit olarak atıcam ve commentsde user_id ve tweet_id tutacağım sonra iç içe twitterdeki gibi bir şey olucak ama bilemedim.