Laravel Community Tools by Tighten

Tag "view data" tricks

55 tricks
If you’re using blade, you can use the following to easily output style and script tags.
hengkiardo 11 years ago 8341
Sometimes you want to render a partial without sharing all the scope. I often found that the scope inheritance between highly decoupled UI modules makes hard to find errors, because we end up using similar variable names in each module (using @include) Let me show you an example:
fedeisas 12 years ago 10220
In the official docs : http://laravel.com/docs/responses#special-responses, need to do `Response::json(...)` to create json response. Actually, if the returned value is an array or instance of arrayableinterface or jsonableinterface such as eloquent model, you could just return it, it'll be a json, magically.
egig 12 years ago 71994
Submit links to a DELETE route with a confirmation box.
jgoux 12 years ago 17564
If you have an API, which you also use on your site..then you might want to get the data from the API by making an internal request.
xtrasmal 12 years ago 19051
Previously, if you wanted to output a default value of a string in Blade you would put a condition that checks if the variable is set, otherwise defaults to some value. Now you can shorten the code by using the keyword "or" to specify what should be displayed if the variable is not set.
msurguy 12 years ago 11269
A Link assets based on which controller is currently requested. Any improvements to this code are welcome
JonathanFr... 12 years ago 11717
This trick is what we use to make writing controllers very quick and easy. The base controller has methods plugged in where needed to automatically load views to a set of templates on it's own. All you need to do is pass it the data you want displayed. It also handles missingmethod to automatically look for logical views. Let me know what you think or any ideas for improving upon it. As a note, I use a separate controller to set the page title and menu items.
stygian 12 years ago 14685
Use laravel pagination with this small bit of jquery to ajax load paginated results. Create a page with the data you wish to paginate. http://www.example.com/paginated/data
riddles888... 12 years ago 44744