Archive | PHP

How to migrate data from Laravel Cashier 5 to 6

In this post I will outline migrating your existing subscription data from Laravel Cashier version 5 to version 6. In version 6, Cashier got a nice update to handle multiple subscriptions but there is not guide to migrate your data. Fear not, it’s actually pretty easy! The first thing you should do is backup your […]

Continue Reading 2
Laravel Logo

Laravel 4 – Pivot vs Polymorphic – Part 1

PHP has come a long way! Coming from the Rails world back to PHP has actually been pretty painless thanks to Laravel. One of the first things that stumped me was under what circumstances to use pivot vs polymorphic relationships. This post is more of a reminder for myself but I hope it clarifies things […]

Continue Reading 2

PHP: Handle comma separated input

A quick example of how to handle comma separated input from a POST variable in PHP. The code below will turn your POST variable into an array containing the user’s input which you can further validate or store in a database. This is useful for letting users add tags to items on your website. $tagsString […]

Continue Reading 1

Check image type in PHP

Quick PHP tip: If you’re looking to determine the type of uploaded image you can use the following code: $type = exif_imagetype($_FILES[‘uploaded_image’][‘tmp_name’]); if ($type == 1 || $type == 2 || $type == 3) { //image type is jpg, gif or png } The code above shows a snippet to check if the uploaded image […]

Continue Reading 0

PHP base_convert() in AS3

Here is a quick example of how to use PHP’s base convert function in AS3. A lot of people use this function for shorter masked URLs like YouTube. Easy enough but took me a minute to find the equivalent in actionscript. PHP: function encode36($x){ return base_convert($x, 10, 36); } function decode36($x){ return base_convert($x, 36, 10); […]

Continue Reading 0