Skip to content

Instantly share code, notes, and snippets.

@jgrossi
Created February 19, 2016 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgrossi/c670451b935e98abb9e6 to your computer and use it in GitHub Desktop.
Save jgrossi/c670451b935e98abb9e6 to your computer and use it in GitHub Desktop.
Fetch posts and page details from a Laravel controller using Corcel
<?php // File: /app/Http/Controllers/AnyController.php
// ...
public function index()
{
$posts = Post::published()->take(10)->get();
$page = Page::where('post_name', 'about')->first();
return view('posts.index', compact('posts', 'page'));
}
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment