use App\User;
use App\Post;
use Session;
class HomeController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
public function index()
{
$users = User::paginate(5);
$posts = Post::paginate(5);
return view('test', compact('users','posts'));
}
{{ count($posts) }}
Undefined variable: posts
return view('test', compact('users','posts'));
return view('test', ['users' => $users,'posts' => $posts]);