Created
April 21, 2016 18:57
-
-
Save sunshain/3de41ae2bc112c32aa72b1e953039c6b 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 | |
/* | |
* add to config/app.php providers | |
* App\Providers\ValidationProvider::class, | |
* | |
* add to lang/validation.php | |
* 'currented' => 'The current password is not correct.', | |
*/ | |
namespace App\Providers; | |
use Illuminate\Support\Facades\Auth; | |
use Illuminate\Support\Facades\Hash; | |
use Illuminate\Support\Facades\Validator; | |
use Illuminate\Support\ServiceProvider; | |
class ValidationProvider extends ServiceProvider | |
{ | |
/** | |
* Bootstrap the application services. | |
* | |
* @return void | |
*/ | |
public function boot() | |
{ | |
Validator::extend('currented', | |
function($attribute, $value, $parameters, $validator) { | |
return Hash::check($value, Auth::user()->password); | |
} | |
); | |
Validator::replacer('currented', | |
function($message, $attribute, $rule, $parameters) { | |
return str_replace(':values', implode(', ', $parameters), $message); | |
} | |
); | |
} | |
/** | |
* Register the application services. | |
* | |
* @return void | |
*/ | |
public function register() | |
{ | |
// | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
окей, а как теперь это вызывать внутри валидатора?