Laravel offers a dynamic interface for assigning certain data. This can be used e.g. for adding a dynamic 'where' to your Eloquent queries. However, not everyone know that this same trick also works on View assignments!
// In Eloquent, you can assigned 'where' clauses dynamically Post::whereSlug('slug')->get(); // Results in ...WHERE `slug` = 'slug'... // The same trick is possible when using Views! View::make('posts.index')->withPosts($posts); // Same as: View::make('posts.index')->with('posts', $posts);
Ads cover the costs of maintaining Laravel-trickscomments powered by Disqus