Smiley Happy Coder

I'm a web developer with a love of technology and I'm a bit of an Apple geek

Debugging live sites with Laravel’s middleware

Try as we might sometimes things just don’t work on the live site like they do on your development or staging sites.

Today I had that exact problem. I have made a change to my application and deployed it.
The change doesn’t work on the live site. Awesome!

Read On >

NFS exports file is invalid in Vagrant

Vagrant Logo

Sometimes you may come up against a random error message when running “Vagrant Up”. Something like “NFS exports file is invalid

NFS exports file is invalid

Read On >

Fetching the last insert ID with Laravel

Its fairly common to need to find the ID of the last inserted record.

You could be adding a product to a table and then adding the product ID to a list of categories. Or a similar process on a blog website.

Read On >

Filling HTML select elements in Laravel

Filling a select element or dropdown box is something developers do all the time. In plain old vanilla PHP you do something like this:-

Select elements in vanilla PHP sudo code

- Query the database for the content of the select element
- Loop through the results and write out the <option value="$id">$name</option>

Read On >

Vagrant sometimes doesn’t refresh my content, whats going on?

I’ve been using Vagrant for a few months now, more specifically a system built on top of Vagrant called Vaprobash by the amazing developer Fideloper. Vagrant is an amazing piece of kit. It’s made my development workflow so much faster and taken away all the nasty pain that comes with MAMP.

Read On >

Database transactions in Laravel

Quite often you’ll need to run two database queries that depend on each other.
Imagine you run an online store and for whatever reason you need to remove a category.
What happens to all the products within that category? You might end up with products sitting in your database that nobody will ever be able to see and they get lost or forgotten.
Read On >

Laravel design patterns and best practices – A review

Recently I was asked if I would be open to reading a new book on Laravel and of course I jumped at the chance. I’ve been using Laravel for a little over a year now and to be honest I’m really enjoying its power and ease of use.
Read On >

All about your user in Laravel’s blade views

In your Laravel projects you will undoubtedly need to display certain links or pieces of information about or for the currently logged in user.

Imagine a simple web application, if the user isn’t logged in then we should surely offer them the chance to.

By the same token it would be weird if when the user was logged in there was still this big button inviting them to log in again. Should that now say “Logout”?

Well, yes it should.

Read On >

A little help debugging Laravel sql queries.

One of the problems with these new fangled frameworks is seeing what actually happens in the background.
Sometimes you just need to see what sql queries are being run, so here is a quick snippet for you.

Pop open your global file

Read On >

Quick Laravel helper to generate Gravatar image

Looking to add a Gravatar image to your Laravel application, of course you are.

Gravatar helper code

If you don’t already have a helpers file go and create one.
Create it in the following folder

Read On >

Aliases, how to configure them in your terminal

If you develop on a mac or linux machine you will almost certainly enter the same terminal commands over and over again.
If you haven’t already you should probably set up some aliases.

Read On >

Laravel Environment Detection

One thing you’re almost certainly going to run into quick quickly in your Laravel career is environment detection.

Laravel users environments so that you can really easily set up differing configurations depending on your live or staging or local environments. The most basic example is database connections.

Read On >