Dynamic View assignments

Submitted by stidges - 10 years ago

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
// Results in ...WHERE `slug` = 'slug'...

// The same trick is possible when using Views!

// Same as: View::make('posts.index')->with('posts', $posts);