Development PHP

how to display the username of the comment in the post with relation table

my relational database image

if I use the code above

name user show in all post

my model


namespace App;

use Illuminate\Database\Eloquent\Model;

class Komen extends Model
    protected $table='komentar_post';


my controller

public function index()

    // dd($id);
    return view('home',compact('post','comment','user'));

my view

@foreach($comments as $cm)

what the corect query i must use

Leave a Reply

Your email address will not be published. Required fields are marked *