Skip to content

Instantly share code, notes, and snippets.

@uno-de-piera uno-de-piera/PostController.php Secret
Created Jun 12, 2019

Embed
What would you like to do?
<?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
You can’t perform that action at this time.