Posts

Showing posts from August, 2020

laravel min max number validation rule

if ( isset ( $request [ 'iMinimumAmount' ]) && isset ( $request [ 'iMaximumAmount' ]) ) { if ( $request [ 'iMinimumAmount' ] >= $request [ 'iMaximumAmount' ] ){ $rules [ 'iMaximumAmount' ] = 'numeric|min: ' .( $request [ 'iMinimumAmount' ]+ 1 ); $msg [ 'iMaximumAmount.min' ] = 'The maximum order amount is less than the minimum order amount.' ; } } $validator = Validator:: make ( $add_laundry , $rules , $msg ); if ( $validator ->fails()) { return redirect()->back()->withErrors( $validator )->withInput( $request ->all()); }

How to check if an integer is within a range of numbers in PHP?

The expression:   ( $min <= $value ) && ( $value <= $max ) will be true if  $value   is between   $min   and   $max , inclusively

How to remove the first character of string in PHP?

 <?php  $str = "geeks";            // Or we can write ltrim($str, $str[0]);  $str = ltrim($str, 'g');            echo $str;  ?> 

get first letter of each word

explode()  on the spaces, then you use the  []  notation to access the resultant strings as arrays: $string = "Community College District" ; $result = "CCD" ; $words = explode ( " " , "Community College District" ); $acronym = "" ; foreach ( $words as $w ) {      $acronym .= $w [ 0 ]; }

Laravel Change Password with Current Password Validation Example

  Step 1: Install Laravel 5.8 first of all, we need to get fresh Laravel 5.8 version application using bellow command, So open your terminal OR command prompt and run bellow command: composer create-project --prefer-dist laravel/laravel blog Step 2: Create a Custom Validation Rule After you can set up for migration and basic auth. I didn't write here to run the migration and basic auth because you know how to do that. now we need to create new validation rules using the following command: php artisan make:rule MatchOldPassword After this, we can see they created a new "Rules" folder with one file on the app directory. you can update on that file like this way: app/Rules/MatchOldPassword.php <? php namespace App \Rules ; use Illuminate \Contracts\Validation\Rule ; use Illuminate \Support\Facades\Hash ; class MatchOldPassword implements Rule { /** * Determine if the validation rule passes. * * @param string $attribute * @param mixed...