Skip to content

Instantly share code, notes, and snippets.

@angusfretwell
Created January 27, 2016 07:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save angusfretwell/5727447fee181e1c168d to your computer and use it in GitHub Desktop.
Save angusfretwell/5727447fee181e1c168d to your computer and use it in GitHub Desktop.
<?php
namespace App\Traits;
use Validator;
trait Validatable
{
protected $rules = [];
protected $errors;
public function validate($data)
{
$validator = Validator::make($data, $this->rules);
if ($validator->fails()) {
$this->errors = $validator->errors;
return false;
}
return true;
}
public function errors()
{
return $this->errors;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment