Skip to content

Instantly share code, notes, and snippets.

View kirkbushell's full-sized avatar

Kirk Bushell kirkbushell

  • Tectonic Digital
  • Sydney
View GitHub Profile
@kirkbushell
kirkbushell / PackageMigrationCommand.php
Last active October 21, 2015 13:20
Laravel 5 migrations for packages
<?php
use Illuminate\Console\Command;
use Illuminate\Container\Container;
class PackageMigrationCommand extends Command
{
/**
* Name of the command.
*
* @param string
class UsersServiceProvider extends ServiceProvider
{
/**
* Defer until needed.
*/
public $defer = true;
/**
* Repositories defined by the users module.
*
@kirkbushell
kirkbushell / gist:aa60d05a39dba9288e25
Last active May 30, 2017 10:06
Value object usage within Laravel Eloquent example
<?php
// In model: Ensures values are consistent
class User extends Eloquent {
public function setEmailAttribute(Email $email) {
$this->attributes['email'] = $email;
}
}
// Value object
class Email {
@kirkbushell
kirkbushell / gist:0a7477ad371b285554b9
Created October 8, 2014 20:01
Deferred service provider overloading other deferred provider objects
class ValidationServiceProvider extends ServiceProvider
{
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = true;
public function register()
@kirkbushell
kirkbushell / gulpfile.js
Created August 24, 2014 21:23
Gulpfile for Laravel 4 projects, with a complete assets workflow
// Load all the required plugins.
var gulp = require('gulp'),
notify = require('gulp-notify'),
exec = require('gulp-exec'),
uglify = require('gulp-uglify'),
concat = require('gulp-concat'),
jshint = require('gulp-jshint'),
rename = require('gulp-rename');
var input = 'assets/',
@kirkbushell
kirkbushell / interceptor.js
Created June 11, 2014 15:27
Angular JS HTTP response interceptor
/**
* Interceptor
* Implements functionality to catch various requests and fire events when they happen. This is generally to ensure
* that responses from the server are handled in a uniform fashion across the application. Also, by firing events
* it allows to have any number of handlers attach to the response.
*
* @author Kirk Bushell
* @date 28th March 2013
*/
var module = angular.module('core.interceptor', []);
@servers(['web' => '111.111.111.111'])
@task('deploy')
cd /var/www
git pull origin master
composer install
php artisan migrate
@endtask
var registration = {
create: function() {
var status = null;
var data = {
id: '',
status: ''
};
this.setStatus = function(value) {
@kirkbushell
kirkbushell / typeahead.js
Last active December 19, 2015 10:39
Typeahead (https://github.com/twitter/typeahead.js) in combination with angular + utilizing models
/**
* Typeahead directive for fields. Expects both a typeahead and location attribute.
*
* @param string typeahead - If a value is provided, this should be a two-way data binding to the model that you would like to utilize in partnership with this plugin.
* @param string location - Where the data can be found for remote queries.
*/
module.directive( 'typeahead', [ '$window', '$timeout', function( $window, $timeout ) {
return {
restrict: 'A',
scope: { model: '=typeahead', value: '@' },
@kirkbushell
kirkbushell / resolver.js
Created June 6, 2013 02:52
Simpe AngularJS service resolver for controller resolution.
var resolver = [ '$q', 'Service', function( $q, Service ) {
var deferred = $q.defer();
Service.query({ paginate: false }, function( data ) {
deferred.resolve( data );
}, function() {
deferred.reject( null );
});
return deferred.promise;