Laravel Community Tools by Tighten

Recent tricks

458 tricks
You may need this basically for security reasons. When somebody installed this plugin (https://wappalyzer.com/download) on the browser, s/he can see all the frameworks and javascript libraries among other things. Wappalyzer uses json to specify what it should be looking for. Check this GitHub Repo to understand how it identifies Laravel (https://github.com/ElbertF/Wappalyzer/blob/master/share/apps.json). So, to hide Laravel from this plugin, you need to edit the Session Cookie Name in /app/config/session.php. Change it from laravel_session to your desire name e.g: yourapp_session. Hope this helps.
amirolzolk... 11 years ago 24670
I made a response macro that makes use of the JSend specification (http://labs.omniti.com/labs/jsend). UPDATE (2014-09-15): Added the setting of the content type.
icylace 11 years ago 7756
Sometimes hasColorSupport() in Symfony\Console..StreamOutput returns false even if there is color support, to make it explicitly know we must call this method before output eg. in fire()
hardevine 11 years ago 8184
In many case you want to display values in blade you can do some check sum like this:
star18bit 11 years ago 16404
I use this to always know in my controllers if the current action is shown through a Facebook tab iframe. Upon the first request this checks if there is a "signed_request" variable posted to the page. Then $fb_state is set to true and shared with all views. The problem is that on navigating to the next page within your app this variable is lost and you don't know if this is shown through facebook. Due to the FB page proxy you can't use sessions to remember this for the next request either. I solve this problem with adding "signed_request" as a parameter (i.e. "&signed_request=123ljshgljsdhflsdhfl") to every link and form when $fb_state == true. Of course you could also pass any other variable if you don't need the actual signed_request data.
flei 11 years ago 8341
When showing a website through a Facebook Page tab validation errors are not displayed, because Facebook "forgets" the sessions due to the page proxy. One problem with this is that session data is destroyed / forgotten on each request going through that proxy. This applies to Redirect::back()->withErrors($validator) for showing the form with validation errors because sessions are used . To avoid this simply fiddle the error data together and pass it directly to the respective action that handles the input form. One thing to mention is that calling other controller actions directly of course does not affect the route. Let's say editing happens at "/edit" and the "registration complete" message is shown at "/complete". Calling the action within the controller the form with errors is now shown at "/complete" whereas "/edit" would be shown if you redirected back (Line 22). I personally don't really care too much about this since the "real" web address is not shown in the FB page tab anyway due to the page proxy. Looking forward to hearing your opinions on this. Maybe there is even a better way.
flei 11 years ago 13840
Sub Form, Cascade Form, Form Inside Form
sayasuhend... 11 years ago 9226
You can chain eager loading to avoid N+1 problem. Suppose you have 3 tables. customer[id, email], pos[id, serial_number] and restaurant[id, name, customer_id, pos_id] so restaurant table can act like a pivot table and it also have some value attribute. So now we can call customer from pos table via chaining eager loading.
milon 11 years ago 20306
By this line adding to the app/routes.php file, you can apply 'csrf' filter to all routes
milon 11 years ago 8521