Skip to content

Instantly share code, notes, and snippets.

@thepsion5
thepsion5 / LaravelValidator.php
Last active November 10, 2016 07:25
Demonstration of a simple wrapper for Laravel's Validator that allows rules to be altered based on input before validating and exceptions as transports for validation errors
<?php
use Illuminate\Support\MessageBag,
Illuminate\Validation\Factory;
/**
* A simple wrapper for Laravel's native validator. Allows
* validation rules to be modified pre-validation based on
* input and can be used to throw an exception with the
* input and validation failures
@thepsion5
thepsion5 / Person Transformer
Last active August 29, 2015 14:00
Simple example of a transformer class
<?php
namespace Infrastructure\Database;
use DateTime,
Domain\Person\PersonEntity as Person,
Domain\Person\Name,
Domain\Person\Email;
class ExamplePersonDomainObjectTransformer extends AbstractTransformer
{
@thepsion5
thepsion5 / controller.php
Last active August 29, 2015 13:56
In example illustration of how to use a base query function to generate a filtered and sorted query without repeating code for each function.
<?php
public function index()
{
if(Input::get('sort')) {
$this->offices->sort(Input::get('sort'), Input::get('direction'));
}
$offices = $this->offices->all();
return View::make('app.offices.list', compact('offices'));
}