new OTP send or resend OTP after 60 seond in php laravel

if (User::where('phone', $input['phone'])->exists()) {
  $success['result']=User::where('phone', $input['phone'])->whereRaw("updated_at >=('" . date('Y-m-d H:i:s') . "'-INTERVAL 60 SECOND) AND updated_at <='" . date('Y-m-d H:i:s') . "'")->exists();
  if(!$success['result']){
    $success['otp']=$otp; 
  $affectedRows = User::where('phone', $input['phone'])->update(array('otp' => $otp,'password'=>Hash::make($otp)));
  }else { $isSend = 0; }
}else{
  $success['result']=false;
  $success['otp']=$otp;
  $input['password'] = Hash::make($otp);
  $input['otp']=$otp;
  $user = User::create($input);
}
if($isSend)
{
$otp_response=json_decode($this->sendOtp($data,$otp));
$success['otp_response']=$otp_response->status;
//$otp_response->status == "success"
}

check redis connection in laravel

For root user

# composer require predis/predis --no-plugins --no-scripts 

For normal user

$ composer require predis/predis

For More

length validation in laravel

 $request->validate([
            'title' => 'max:149',            
            'category' => 'max:99',
            'summary' => 'max:299',
            'description' => 'max:8000',            
            'thumb' => 'max:50',
            'image' => 'max:300',            
        ]);

display error in laravel blade

@foreach ($errors->all() as $error)
<div class="col-11">
<div class="alert alert-warning">
{{ $error }}
</div>
</div>
@endforeach

show current connection in laravel controller

 if(isset($_SESSION['database'])){
            App::setLocale($_SESSION['database']);
            Config::set('database.connections.mysql.database', $_SESSION['database']); 
            } 
echo DB::connection()->getDatabaseName()." ".$_SESSION['database'];
        echo DB::connection()->getName()." ".$_SESSION['database'];

composer fund

composer fund
Do not run Composer as root/super user! See https://getcomposer.org/root for det ails
Continue as root/super user [yes]? y
Info from https://repo.packagist.org: #StandWithUkraine
The following packages were found in your dependencies which publish funding inf ormation:

brick
math
https://github.com/sponsors/BenMorel
https://tidelift.com/funding/github/packagist/brick/math

doctrine
inflector, instantiator, lexer
https://www.doctrine-project.org/sponsorship.html
https://www.patreon.com/phpdoctrine
inflector
https://tidelift.com/funding/github/packagist/doctrine%2Finflector
instantiator
https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator
lexer
https://tidelift.com/funding/github/packagist/doctrine%2Flexer

dragonmantank
cron-expression
https://github.com/sponsors/dragonmantank

egulias
email-validator
https://github.com/sponsors/egulias

facade
flare-client-php
https://github.com/sponsors/spatie

filp
whoops
https://github.com/sponsors/denis-sokolov

fruitcake
laravel-cors
https://fruitcake.nl
https://github.com/sponsors/barryvdh

graham-campbell
result-type
https://github.com/sponsors/GrahamCampbell
https://tidelift.com/funding/github/packagist/graham-campbell/result-type

guzzlehttp
guzzle, promises, psr7
https://github.com/sponsors/GrahamCampbell
https://github.com/sponsors/Nyholm
guzzle
https://tidelift.com/funding/github/packagist/guzzlehttp/guzzle
promises
https://tidelift.com/funding/github/packagist/guzzlehttp/promises
psr7
https://tidelift.com/funding/github/packagist/guzzlehttp/psr7

lcobucci
jwt
https://github.com/sponsors/lcobucci
https://www.patreon.com/lcobucci

league
commonmark
https://www.colinodell.com/sponsor
https://www.paypal.me/colinpodell/10.00
https://github.com/sponsors/colinodell
https://tidelift.com/funding/github/packagist/league/commonmark
flysystem
https://offset.earth/frankdejonge
flysystem, mime-type-detection
https://github.com/sponsors/frankdejonge
https://tidelift.com/funding/github/packagist/league/flysystem
oauth2-server
https://github.com/sponsors/sephster
uri, uri-interfaces
https://github.com/sponsors/nyamsprod

monolog
monolog
https://github.com/sponsors/Seldaek
https://tidelift.com/funding/github/packagist/monolog/monolog

myclabs
deep-copy
https://tidelift.com/funding/github/packagist/myclabs/deep-copy

nesbot
carbon
https://opencollective.com/Carbon
https://tidelift.com/funding/github/packagist/nesbot/carbon

nunomaduro
collision
https://www.paypal.com/paypalme/enunomaduro
https://github.com/sponsors/nunomaduro
https://www.patreon.com/nunomaduro

nyholm
psr7
https://github.com/sponsors/Zegnat
https://github.com/sponsors/nyholm

phar-io
manifest
https://github.com/sponsors/theseer

phpoption
phpoption
https://github.com/sponsors/GrahamCampbell
https://tidelift.com/funding/github/packagist/phpoption/phpoption

phpseclib
phpseclib
https://github.com/sponsors/terrafrost
https://www.patreon.com/phpseclib
https://tidelift.com/funding/github/packagist/phpseclib/phpseclib

phpunit
php-code-coverage, php-file-iterator, php-invoker, php-text-template, php-time r, phpunit
https://github.com/sponsors/sebastianbergmann
phpunit
https://phpunit.de/sponsors.html

ramsey
collection, uuid
https://github.com/sponsors/ramsey
collection
https://tidelift.com/funding/github/packagist/ramsey/collection
uuid
https://tidelift.com/funding/github/packagist/ramsey/uuid

sebastian
cli-parser, code-unit, code-unit-reverse-lookup, comparator, complexity, diff, environment, exporter, global-state, lines-of-code, object-enumerator, object-r eflector, recursion-context, resource-operations, type, version
https://github.com/sponsors/sebastianbergmann

spatie
laravel-permission
https://github.com/sponsors/spatie

swiftmailer
swiftmailer
https://github.com/sponsors/fabpot
https://tidelift.com/funding/github/packagist/swiftmailer/swiftmailer

symfony
console, css-selector, deprecation-contracts, error-handler, event-dispatcher, event-dispatcher-contracts, finder, http-foundation, http-kernel, mime, polyfil l-ctype, polyfill-iconv, polyfill-intl-grapheme, polyfill-intl-idn, polyfill-int l-normalizer, polyfill-mbstring, polyfill-php72, polyfill-php73, polyfill-php80, polyfill-php81, process, psr-http-message-bridge, routing, service-contracts, s tring, translation, translation-contracts, var-dumper
https://symfony.com/sponsor
https://github.com/sponsors/fabpot
https://tidelift.com/funding/github/packagist/symfony/symfony

theseer
tokenizer
https://github.com/sponsors/theseer

vlucas
phpdotenv
https://github.com/sponsors/GrahamCampbell
https://tidelift.com/funding/github/packagist/vlucas/phpdotenv

voku
portable-ascii
https://www.paypal.me/moelleken
https://github.com/sponsors/voku
https://opencollective.com/portable-ascii
https://www.patreon.com/voku
https://tidelift.com/funding/github/packagist/voku/portable-ascii

Please consider following these links and sponsoring the work of package authors !
Thank you!

sudo composer update

sudo composer update

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

composer reload laravel 8 | Composer Update Laravel

If on some environment you do not want to trigger any scripts, you can prevent this using the --no-scripts flag.

composer update --no-scripts
composer dump-autoload
php composer.phar update --dev
$ sudo -H composer self-update
$ composer update --ignore-platform-reqs
$ composer self-update --rollback 
$ composer install
php artisan clear-compiled 
composer dump-autoload
php artisan optimize
composer diagnose

Laravel spatie permissions and roles

Direct Permissions

composer show spatie/laravel-permission

A permission can be given to any user:

$user->givePermissionTo('edit articles');

// You can also give multiple permission at once
$user->givePermissionTo('edit articles', 'delete articles');

// You may also pass an array
$user->givePermissionTo(['edit articles', 'delete articles']);

A permission can be revoked from a user:

$user->revokePermissionTo('edit articles');

Or revoke & add new permissions in one go:

$user->syncPermissions(['edit articles', 'delete articles']);

You can check if a user has a permission:

$user->hasPermissionTo('edit articles');

Or you may pass an integer representing the permission id

$user->hasPermissionTo('1');
$user->hasPermissionTo(Permission::find(1)->id);
$user->hasPermissionTo($somePermission->id);

You can check if a user has Any of an array of permissions:

$user->hasAnyPermission(['edit articles', 'publish articles', 'unpublish articles']);

…or if a user has All of an array of permissions:

$user->hasAllPermissions(['edit articles', 'publish articles', 'unpublish articles']);

You may also pass integers to lookup by permission id

$user->hasAnyPermission(['edit articles', 1, 5]);

Saved permissions will be registered with the Illuminate\Auth\Access\Gate class for the default guard. So you can check if a user has a permission with Laravel’s default can function:

$user->can('edit articles');

default value in Laravel migration

Put the default value in single quote and it will work as intended. An example of migration:

$table->increments('id');
            $table->string('name');
            $table->string('url')->nullable();
            $table->string('country')->default('india');
            $table->tinyInteger('status')->default('1');
            $table->timestamps();