$posts = DB::table('posts')
->join('users', 'posts.user_id', '=', 'users.id')
->orderBy('publish_at', 'desc')->get()
public function user()
{
return $this->belongsTo(User::class);
}
Post::with('user')->orderBy('publish_at', 'desc')->get();
$posts = DB::table('posts')->select(DB::raw('posts.*, users.username'))
->join('users', 'posts.user_id', '=', 'users.id')
->orderBy('publish_at', 'desc')->get();