Skip to content

Instantly share code, notes, and snippets.

abstract class Document {
final protected static $table;
public function getTable()
{
return self::$table;
}
}
<?php
/** Abstract Repository Class **/
abstract class PostRepository {
public function create(array $input)
{
$post = $this->_create($input);
if ($post) {
<?php namespace ProgrammingAreHard\Data\Validators;
use Illuminate\Validation\Validator;
class ValidationService implements ValidatorInterface {
protected $validator;
protected $errors = [];
<?php namespace ProgrammingAreHard\Data\Validators;
interface HasModelRules {
/**
* Get the validation rules for the model when creating
*
* @return array
*/
public function getRulesForCreate();
<?php namespace ProgrammingAreHard\Data\Validators;
class UserValidation implements HasModelRules {
/**
* Laravel validation ruleset for model creation
*
* @var array
*/
private static $rulesForCreate = [
<?php namespace MyApp\Validators;
use ProgrammingAreHard\Data\Validators\UserValidation;
use ProgrammingAreHard\Data\Validators\ValidationService;
use ProgrammingAreHard\Data\Validators\ValidatorInterface;
class RegistrationValidator implements ValidatorInterface {
/**
* @var \ProgrammingAreHard\Data\Validators\ValidationService
@dadamssg
dadamssg / gist:7029609
Created October 17, 2013 18:12
line 3202
<?php
//more code
if (false) {
$multiQuery = "";
foreach($queryDeleteArray as $inx => $singleQuery) {
$multiQuery .= $singleQuery . $this->getSql()->getMultiStatementDelimiter();
}
$this->getSql()->doExec($multiQuery);
<?php
//change this
Route::get('/blog', function()
{
Route::get( 'blog', 'BlogController@index' );
});
//to this
Route::get( 'blog', 'BlogController@index' );
@dadamssg
dadamssg / base.blade.php
Last active December 25, 2015 21:19
views/base.blade.php
<html>
<body>
<div class="container">
@yield('content')
</div>
</body>
</html>
<?php
class DoctrineProductRepository implements ProductRepository {
//entity manager
protected $em;
public function addCategory(ProductInterface $product, CategoryInterface $category)
{
$product->setCategory($category);