Skip to content

Instantly share code, notes, and snippets.

View craigh411's full-sized avatar
😀

Craig Humphreys craigh411

😀
View GitHub Profile
<?php
namespace App\Console\Commands;
use App\Ami;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Component\Process\Process;
Smith,
Johnson,
Williams,
Brown,
Jones,
Garcia,
Miller,
Davis,
Rodriguez,
Martinez,
@craigh411
craigh411 / CountrySeeder.php
Created March 28, 2017 14:41
Country Names Seeder for Laravel 5.x
<?php
use Carbon\Carbon;
use Illuminate\Database\Seeder;
class CountrySeeder extends Seeder
{
public function addCountries(array $countries)
{
@craigh411
craigh411 / select2-vuejs-component.md
Last active March 31, 2021 23:28
Vue.js component for Select2

#Vue.js component for Select2

A select2 component for vue.js. Quickly create select2 components, load data via ajax and retrieve selected values and newly created tags.

#Usage

Download and register the component:

Vue.component(

Simple jQuery plugin for checking all checkboxes on a page by a given class name.

Usage

HTML

<input type="checkbox" id="checkAll" />
@craigh411
craigh411 / README.md
Last active October 20, 2015 12:46
Trait to help with Laravels unique validator

Laravel 5.1 Helper Trait for using unique

In Laravel the unique validation rule will trigger even when you are updating the original record, unless you provide some logic in your FormRequest to exclude the record when updating. This trait can be used to avoid that logic by detecting when a record is being created or updated.

Usage

Place the trait in app\Http\Traits (if using a different directory simply change the namespace) and then use it inside your form request or add it to the app\Requests\Request.php:

use App\Http\Traits\ValidationHelper

@craigh411
craigh411 / laravel.js
Created October 19, 2015 16:48 — forked from soufianeEL/laravel.js
You use Laravel 5 and you want to send a DELETE request without creating a form? This will handle the form-creation bits for you dynamically, similar to the Rails implementation. To use, import script, and create a link with the `data-method="DELETE"` and `data-token="{{csrf_token()}}"` attributes.
/*
Exemples :
<a href="posts/2" data-method="delete" data-token="{{csrf_token()}}">
- Or, request confirmation in the process -
<a href="posts/2" data-method="delete" data-token="{{csrf_token()}}" data-confirm="Are you sure?">
*/
(function() {
@craigh411
craigh411 / KO-SORTABLE-TABLE-README.MD
Last active October 2, 2015 13:54
Knockout binding handler for sortable table rows using jQuery UI.

Create Sortable Table rows using KnockoutJS and jQuery UI

Custom binding handler for sorting table rows. It overrides the helper option of jQuery sortable to make sure that the table row

keeps it's width and attempts to set the correct background colour for the helper, however, background can be set by passing in the helperBg parameter:

<table data-bind="sortableTable: {'helperBg': '#000000'}">

Basic Usage: