Laravel Community Tools by Tighten

Category "Requests and Input" tricks

68 tricks
Catch all routes and paths using the auth filter. A route validation method is added to the Users model called hasAccess($route) and returns true if the user has that route. If the user doesn't have the route the error message will inform of what access they are missing.
somadden 12 years ago 9871
If you have an array like: array( array('key' => 'value'), array('key' => 'anotherValue'), array('key' => 'sameValue'), array('key' => 'sameValue') ); and you want to make sure that you cant have 'key' with same value twice i was searching a native way to do it, but couldn't find one - so this is my solution:
dani3l 12 years ago 10658
4.1
Perform pattern based CSRF filter on all post, put, patch, and delete requests. Just add this code snippet at the top of routes.php
Illusion 12 years ago 6568
This stumped me for some time and after digging around I found it works great, the uploaded file can be removed from the server as well as the database entry. works well for file sharing and image sharing sites.
blackrain 12 years ago 22503
A Controller-based solution to add the CSRF filter to all POST requests.
danalloway 12 years ago 8920
Laravel passes 100% test coverage on Hip Hop Virtual Machine (HHVM) so you might want to try using it to host your next Laravel application. The advantage of HHVM is an increase in speed of executing your PHP scripts and thus boosting your application. This config was provided by Taylor Otwell.
msurguy 12 years ago 21521
Submit links to a DELETE route with a confirmation box.
jgoux 12 years ago 17548
Do not trust the client. Safe way to get CSRF token for use in Angular JS. Keeps it as a constant.
xtrasmal 12 years ago 42018
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 19039