Amazon's S3 is a great solution for storing files, and Laravel makes it easy to use. Occasionally you'll need to force files to download instead of just showing it in the browser, but thankfully this is easy too! Rather than wasting your server resources to streaming the file from S3 to your user, we're going to be using signed URLs. Signed URLs can give a user temporary access to a specific file in your private bucket, so we just need to redirect there and tell S3 to set an extra header. In your controller responsible for downloading files, you'll just…

Starting with Google Chrome v63, any domain using the .dev extension will be forced to use HTTPS. What does this mean? If you're using .dev in combination with Laravel Valet, you should switch to .test which is reserved specifically for developer use. You can easily do this by running the following Valet command: valet domain test Once you've done this, don't forget to update the APP_URL in your project's .env file and you should be good to go.…

When building an application that handles events, appointments, or any sort of data with a start and end time, you'll eventually find that you need to do a MySQL query for events that overlap a date range. The two most common uses include: Allow users to filter events by date range Ensuring calendar appointments don't overlap If you've never written a query to do this before, it can be confusing and easily overcomplicated. Thankfully it's actually pretty simple. The Solution I figure some of you will just want the solution, so we'll start there and work backwards. Assume we have…

With Bootstrap 4 now in beta, many people are beginning to switch their projects over to V4. Obviously the migration process requires changing existing markup, which you can learn more about in the official guide), but for this guide I'll only be covering how to integrate it in your Laravel Mix build process. Remove the old Bootstrap dependency To remove the old dependency, we just need to run this command in our project directory: npm uninstall bootstrap-sass --save-dev Install the beta dependencies We'll need to install both the Bootstrap 4 beta as well as Popper.js (used by Bootstrap for…

One of the many useful features of Eloquent is the ability to define accessors and mutators. Mutators can help you if there's something you'd like to do with a value (like hashing a password) every time it gets set on your model. Accessors are for doing something every time you retrieve an attribute (like converting markdown to HTML). You can even use an accessor to dynamically create additional properties on your model (like a full name that concatenates first and last names). Those are great features, but we also have attribute casting so we can convert attributes to common data…