Search
 
SCRIPT & CODE EXAMPLE
 

PHP

validate password laravel

        $request->validate([
            'email' =>'required|exists:users',
            'password'=>'required|password'
        ]);
Comment

laravel validate change password

<?php
   
namespace AppHttpControllers;
   
use IlluminateHttpRequest;
use AppRulesMatchOldPassword;
use IlluminateSupportFacadesHash;
use AppUser;
  
class ChangePasswordController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('auth');
    }
   
    /**
     * Show the application dashboard.
     *
     * @return IlluminateContractsSupportRenderable
     */
    public function index()
    {
        return view('changePassword');
    } 
   
    /**
     * Show the application dashboard.
     *
     * @return IlluminateContractsSupportRenderable
     */
    public function store(Request $request)
    {
        $request->validate([
            'current_password' => ['required', new MatchOldPassword],
            'new_password' => ['required'],
            'new_confirm_password' => ['same:new_password'],
        ]);
   
        User::find(auth()->user()->id)->update(['password'=> Hash::make($request->new_password)]);
   
        dd('Password change successfully.');
    }
}
Comment

laravel validate change password

<?php
  
namespace AppRules;
  
use IlluminateContractsValidationRule;
use IlluminateSupportFacadesHash;
  
class MatchOldPassword implements Rule
{
    /**
     * Determine if the validation rule passes.
     *
     * @param  string  $attribute
     * @param  mixed  $value
     * @return bool
     */
    public function passes($attribute, $value)
    {
        return Hash::check($value, auth()->user()->password);
    }
   
    /**
     * Get the validation error message.
     *
     * @return string
     */
    public function message()
    {
        return 'The :attribute is match with old password.';
    }
}
Comment

PREVIOUS NEXT
Code Example
Php :: Non-static method called statically php 
Php :: run composer with specific php version 
Php :: codeigniter select where 
Php :: get all taxonomy name wordpress 
Php :: laravel migration change column order 
Php :: mktime syntax php 
Php :: php mysqli insert name adress 
Php :: Keep values in search form after submit 
Php :: Function create_function() is deprecated in 
Php :: laravel create custom route file 
Php :: loginByUserID in conrete 
Php :: php increment variable 
Php :: laravel select only one word from string 
Php :: twig to pdf 
Php :: remove duplicate characters in a string in php 
Php :: truncate url rewrites magento 2 database 
Php :: how to reverse a string in php 
Php :: windows list registered applications 
Php :: twig render string 
Php :: php md5 password is insecure 
Php :: twig filter array 
Php :: single sign on php script 
Php :: php declare variable 
Php :: php serve a video (THE ONLY WORKING CODE) 
Php :: phpstorm using extract to create variales 
Php :: laravel return a single dimensional array 
Php :: get attachment by id wordpress 
Php :: laravel schedule kernel code sample 
Php :: paginate array before more results php 
Php :: Ajax refreshing custom mini-cart count and content in Woocommerce 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =