Created
January 27, 2016 07:54
-
-
Save angusfretwell/5727447fee181e1c168d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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