Created
September 17, 2014 20:22
-
-
Save tiagodavi/72a506e0d10db1194a6f to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
// app/classes/myrules.php | |
class MyRules | |
{ | |
// note this is a static method | |
public static function _validation_unique($val, $options) | |
{ | |
list($table, $field, $id) = explode('.', $options); | |
$result = DB::select("LOWER (\"$field\")", 'id') | |
->where($field, '=', Str::lower($val)) | |
->from($table) | |
->execute(); | |
if($result->count() > 0){ | |
$data = $result->as_array(); | |
return (empty($id)) ? false : ($data[0]['id'] == $id); | |
}else{ | |
return true; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment