-
-
Save uno-de-piera/f99db451d33da6e7cd2ea8f3319dab18 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers; | |
use App\Models\Post; | |
class PostController extends Controller | |
{ | |
public function index () { | |
$posts = Post::select('id', 'user_id', 'title', 'content', 'created_at')->with([ | |
'user' => function ($query) { | |
$query->select('id', 'name'); | |
} | |
])->paginate(config('constants.pagination.per_page'); | |
return view('posts', compact('posts')); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment