Skip to content

Instantly share code, notes, and snippets.

View alchemydigital's full-sized avatar

Alchemy Digital alchemydigital

View GitHub Profile
@alchemydigital
alchemydigital / L4-SuperEloquent.php
Last active August 29, 2015 14:18
A simple extension to Eloquent to easily perform functions before a model is saved (Laravel 4)
<?php
class SuperEloquent extends Eloquent
{
protected $before_save = array();
public function __construct($attributes = array())
{
parent::__construct($attributes);
}
@alchemydigital
alchemydigital / countries.php
Last active August 29, 2015 14:18
Countries and US states with their two-character ISO short code - useful for creating select menus of countries for payment details.
<?php
return array(
/*
|--------------------------------------------------------------------------
| ISO Countries
|--------------------------------------------------------------------------
|
| Associative array of all countries with their two-character ISO code
|
@alchemydigital
alchemydigital / gist:ab0eb238910e9c8a18c4
Last active September 29, 2022 11:47
Manually instantiating Glide using a different class (use with this Gist - https://gist.github.com/alchemydigital/2e3a2b7261e36003e42f). Basically the same as the manual setup in the docs, except with a different Server class - http://glide.thephpleague.com/config/the-server/.
<?php
// Set image source
$source = new League\Flysystem\Filesystem(
new League\Flysystem\Adapter\Local('path/to/source/folder')
);
// Set image cache
$cache = new League\Flysystem\Filesystem(
new League\Flysystem\Adapter\Local('path/to/cache/folder')
);
@alchemydigital
alchemydigital / gist:2e3a2b7261e36003e42f
Created March 18, 2015 04:16
Class to extend the Glide Server and enable correct auto-orientation
<?php namespace Your\App\Namespace;
use League\Glide\Server as Glide;
use League\Glide\Http\NotFoundException;
class Server extends Glide {
public function makeImage()
{
$request = $this->resolveRequestObject(func_get_args());