Skip to content

Instantly share code, notes, and snippets.

View JordanDalton's full-sized avatar

Jordan Dalton JordanDalton

View GitHub Profile
@JordanDalton
JordanDalton / Presenter Class.php
Created August 20, 2014 18:12
PHPStorm file template for quickly generating a presenter that utilizes Shawn McCool's Laravel-Auto-Presenter.
#if (${NAMESPACE})
<?php namespace ${NAMESPACE};
#else
<?php
#end
use McCool\LaravelAutoPresenter\BasePresenter;
class ${NAME} extends BasePresenter {
@JordanDalton
JordanDalton / Eloquent Model.php
Created August 20, 2014 18:19
Simple PHPStorm file template for creating a Eloquent-extended model inside of a namespace.
#if (${NAMESPACE})
<?php namespace ${NAMESPACE};
#else
<?php
#end
use Eloquent;
class ${NAME} extends Eloquent {
@JordanDalton
JordanDalton / Model.php
Last active June 5, 2016 23:55
Here's a simple, real-world example of implementation and extension of models and presenters.
<?php namespace Acme\Core;
use Eloquent;
class Model extends Eloquent {}
@JordanDalton
JordanDalton / UpdateUserRequest.php
Last active August 29, 2015 14:05
Here is an example of how you can utilize Laravel 4.3 FormRequest to force a unique rule to ignore a given ID
<?php namespace App\Http\Requests;
use Auth;
use Illuminate\Foundation\Http\FormRequest;
class UpdateUserRequest extends FormRequest {
/**
* Get the validation rules that apply to the request.
*
@JordanDalton
JordanDalton / StoreUserFormRequest.php
Last active August 29, 2015 14:24
Flexible errors with support for error bags.
<?php
namespace App\Http\Requests;
use App\Http\Requests\Request;
class StoreUserFormRequest extends Request
{
/**
* The key to be used for the view error bag.
@JordanDalton
JordanDalton / AppServiceProvider.php
Last active August 27, 2019 19:00
Here's a nice, common App Service Provider I created and use in 100% of my applications. It provides a simple way to define and bind contracts, define model observers as well as extend form validation extension.
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Validator;
class AppServiceProvider extends ServiceProvider
{
/**
@JordanDalton
JordanDalton / gist:b2488cc840021b017df9a68120323e7e
Created December 10, 2016 19:20
A working curl request for IBM speech to text
curl -X POST -u "{username}":"{password}" --header "Content-Type: audio/wav;codec=pcm;bit=16;rate=16000" --header "Accept: application/json" --header "Transfer-Encoding: chunked" --data-binary @file.wav "https://stream.watsonplatform.net/speech-to-text/api/v1/recognize?model=en-US_NarrowbandModel&speaker_labels=true"
@JordanDalton
JordanDalton / Auditable.php
Created March 14, 2017 16:25
Here's how you could use a trait to update the fillable property on eloquent models.
<?php
namespace App\Traits;
trait Auditable
{
/**
* The fillable properties for this trait which will be applied to the model.
*
* @var array
@JordanDalton
JordanDalton / Employee.php
Created September 23, 2017 21:29
Here's an example of what do to if you desire to use Laravel's updateExistingPivot() while getting your attributes mutated through a pivot model.
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
class Employee extends Model
{
/**
@JordanDalton
JordanDalton / Chat.vue
Last active July 14, 2018 22:05
A beauty of leveraging Eloquent to prepare your urls is that your Vue components no longer care about the urls, just that a url is provided.
<script>
export default {
props : [
'messages_url',
'store_message_url'
],
data(){
return {