Laravel

Using View Composers in Laravel 5.2

I have started using Laravel's View Composers which come in handy when you have a navigation bar that constantly needs certain data. For example, you have an ecommerce store and you need to poll how many items a user has in their basket on pretty much every page they move onto, or you need a login/register button when a user isn't logged in and then a profile options button when they are. You could be really lazy and add the same code/query into every single controller, which yes, that will work, but then that's not DRY (Don't Repeat Yourself). To fix this, we can complete a couple of simple steps and have one bit of code which will constantly be in use every time a certian partial is called.

By Michael Brooks, ago
Laravel

Laravel 4: How To Use Jquery UI Sortable

I needed a way to change the sort order of my data inside of an admin interface which I have created. After a little looking around, I found many tutorials which would show how to get this done with JQuery, but wouldn't show the best way to handle this data (and in my case using Laravel to handle this data)...

By Michael Brooks, ago
Laravel

Nice little Laravel tip (Blade Ternary Operator)

Just today, I was looking at using a ternary operator in Laravel's Blade templating system and thought to myself... "There must be a better way of doing this". After a quick Google aanndd... BEHOLD THE OR STATEMENT! Since version 4.1 they managed to sneak in this "or" statement and it's managed to bypass so many people (I figured this out by the lack of voices shouting about this on Google).

By Michael Brooks, ago