mardi 10 octobre 2023

How do I upgrade the version of a Laravel project? do I have to go through each and every update? (I have to go from 5.0 to 10.x)

I am a web development Intern, I am inexperienced. I have to upgrade my Laravel project from the version 5.0 to 10.x, should I incrementally update through each and every versions like 5.1, 5.2 , (5. ....) ... to 8.x, 9.x, 10.x? or is there are anything that web developers do to make it simple? also, can I copy and paste all the elements like models, views and controllers into a new project according to the new directory structure?

I tried to ask chatGPT about this and it said that I will have to go through each and every upgrade.



via Chebli Mohamed

lundi 9 octobre 2023

Laravel 10 Auth Login not working with custom Users table and column names

Info

I have custom name an columns for my Users table and I'm using MSSQL for database. My table is called 'TUsers' and for columns I'm using PascalCase so I have:

  • 'Email' instead of 'email'
  • 'Password' instead of 'password'
  • And all others like created_at, updated_at and remember_token

Registering works fine but there the user is automatically logged in with Auth::login()

The problem

Trying to login returns error "These credentials do not match our records." I have also tried to make a custom LoginController with my own function and I get the same issue using Auth::attempt

  • Tried using bcrypt() as well

What I've tried

I've added this to my User model

public $table = "TUsers";
protected $primaryKey = 'TUserID';

const EMAIL = 'Email';
const PASSWROD = 'Password';
const CREATED_AT = 'CreatedAt';
const UPDATED_AT = 'UpdatedAt';

public function getAuthPassword()
{
    return $this->Password;
}

protected $fillable = [
    'Name',
    'Email',
    'Password',
    'EmailVerifiedAt'
];

protected $hidden = [
    'Password',
    'RememberToken',
];

protected $casts = [
    'EmailVerifiedAt' => 'datetime',
    'Password' => 'hashed',
];

I've also made the following adjustments to auth.php

    'guards' => [
    'web' => [
        'driver' => 'session',
        'provider' => 'users',
        'credentials' => [
            'email' => 'Email',
            'password' => 'Password'
        ]
    ],
],
    'passwords' => [
    'users' => [
        'provider' => 'users',
        'table' => 'PasswordResets',
        'expire' => 60,
        'throttle' => 60,
    ],
],

I've also tried mkaing a custom TUserProvider

<?php
namespace App\Providers;

use Illuminate\Contracts\Auth\UserProvider;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Support\Facades\DB;

class TUsersProvider implements UserProvider
{
    public function retrieveById($identifier)
    {
        return DB::table('TUsers')->where('TUserID', $identifier)->first();
    }

    public function retrieveByToken($identifier, $token)
    {
        return DB::table('TUsers')->where('TUserID', $identifier)->where('RememberToken', $token)->first();
    }

    public function retrieveByCredentials(array $credentials)
    {
        // Retrieve a user by their credentials ('Email' and validate the 'Password')
        $user = DB::table('TUsers')->where('Email', $credentials['Email'])->first();

        if ($user && password_verify($credentials['Password'], $user->Password)) {
            return $user;
        }

        return null;
    }

    public function validateCredentials(Authenticatable $user, array $credentials)
    {
        return password_verify($credentials['Password'], $user->getAuthPassword());
    }

    public function updateRememberToken(Authenticatable $user, $token)
    {
        DB::table('TUsers')->where('TUserID', $user->getAuthIdentifier())->update([
            'RememberToken' => $token,
        ]);
    }
}

And added the following to AuthServiceProvider

   $this->app['auth']->provider('tusers', function ($app, array $config) {
        return new TUsersProvider($app['hash'], $config['model']);
    });

And updated in auth.php the 'provider' parameter under guards.web to 'tusers'.

But then I get the error:

Illuminate\Auth\SessionGuard::__construct(): Argument #2 ($provider) must be of type Illuminate\Contracts\Auth\UserProvider, null given, called in /var/www/html/clients/markj/iatse-new/vendor/laravel/framework/src/Illuminate/Auth/AuthManager.php on line 127



via Chebli Mohamed

Pusher error: auth_key should be a valid app key

guys I did try work with edit and when I click on submit I have this error, but the changes was done and I am guessing why I have this issue

Pusher error: auth_key should be a valid app key .

This is my broadcasting.php

'pusher' => [
        'driver' => 'pusher',
        'key' => env('PUSHER_APP_KEY'),
        'secret' => env('PUSHER_APP_SECRET'),
        'app_id' => env('PUSHER_APP_ID'),
        'options' => [
            'cluster' => env('PUSHER_APP_CLUSTER'),
            'encrypted' => false,
            'useTLS' => false,
            'scheme' => 'http',
            // 'host' => env('PUSHER_HOST'),
            // 'port' => env('PUSHER_PORT', 6379),
            'scheme' => env('PUSHER_SCHEME', 'http'),
            'curl_options' => [
                CURLOPT_SSL_VERIFYHOST => 0,
                CURLOPT_SSL_VERIFYPEER => 0,
            ]
          
        ],
    ],

And this .env file

PUSHER_APP_ID=995591
PUSHER_APP_KEY=644a4ac1988060882370
PUSHER_APP_SECRET=739696537f4fb23b8fcd
PUSHER_APP_CLUSTER=ap1
PUSHER_PORT=6379
PUSHER_SCHEME=http
PUSHER_HOST_PROXY=${HOST}
PUSHER_PATH_PROXY='/websockets'
PUSHER_PORT_PROXY=443
PUSHER_HOST=127.0.0.1
MIX_PUSHER_HOST=${HOST}


via Chebli Mohamed

vendredi 6 octobre 2023

Why laravel users get looged out everytime I deploy an app to heroku

We are using Laravel 5 and spatie-permissions package. Every time we commit something to the master branch, everything gets rebuilt.

Could that be the cause of invalidating all user sessions?

PHP version is 7.4.33. We used auth0 for user login earlier, should we remove it from composer.json?

I've attached the log below

-----> Building on the Heroku-20 stack  
-----> Using buildpacks:  
       1. heroku/php  
       2. https://github.com/harrylewis/heroku-buildpack-potrace.git  
-----> PHP app detected  
-----> Bootstrapping...  
  
 !     WARNING: Your 'composer.lock' is out of date!  
 !   
 !     The 'composer.lock' file in your project is not up to date with  
 !     the main 'composer.json' file. This may result in installation  
 !     of incorrect packages or package versions.  
 !   
 !     The lock file is required in order to guarantee reliable and  
 !     reproducible installation of dependencies across systems and  
 !     deploys. It must always be kept in sync with 'composer.json'.  
 !   
 !     Whenever you change 'composer.json', ensure that you perform  
 !     the following steps locally on your computer:  
 !     1) run 'composer update'  
 !     2) add all changes using 'git add composer.json composer.lock'  
 !     3) commit using 'git commit'  
 !   
 !     Ensure that you updated the lock file correctly, and that you  
 !     ran 'git add' on both files, before deploying again.  
 !   
 !     Please remember to always keep your 'composer.lock' updated in  
 !     lockstep with 'composer.json' to avoid common problems related  
 !     to dependencies during collaboration and deployment.  
 !   
 !     Please refer to the Composer documentation for further details:  
 !     https://getcomposer.org/doc/  
 !     https://getcomposer.org/doc/01-basic-usage.md  
  
-----> Preparing platform package installation...  
-----> Installing platform packages...  
       - php (7.4.33)  
       - ext-oauth (2.0.7)  
       - ext-memcached (3.2.0)  
       - ext-imagick (3.7.0)  
       - ext-ftp (bundled with php)  
       - apache (2.4.57)  
       - composer (2.6.4)  
       - nginx (1.24.0)  
       - ext-gd (bundled with php)  
       NOTICE: detected userland polyfill packages for PHP extensions  
       NOTICE: now attempting to install native extension packages  
       Installing extensions provided by symfony/polyfill-mbstring:  
       - ext-mbstring...   
       Installing extensions provided by symfony/polyfill-iconv:  
       - ext-iconv...   
       Installing extensions provided by symfony/polyfill-ctype:  
       - ext-ctype...   
  
 !     WARNING: Your selected PHP version has reached end-of-life  
 !   
 !     No updates or security fixes have been provided for your PHP  
 !     version series by the PHP Group since 2022-11-28.  
 !   
 !     It is strongly recommended you update your app to a version of  
 !     PHP with "active support" status immediately to ensure you get  
 !     the latest bugfixes and security updates each time you deploy.  
 !   
 !     You may check the list of versions supported by the PHP Group  
 !     and their EOL dates here: http://php.net/supported-versions.php  
 !   
 !     For a list of supported runtimes & extensions on Heroku, please  
 !     refer to: https://devcenter.heroku.com/articles/php-support  
  
-----> Installing dependencies...  
       Composer version 2.6.4 2023-09-29 10:54:46  
       Installing dependencies from lock file  
       Verifying lock file contents can be installed on current platform.  
       Warning: The lock file is not up to date with the latest changes in composer.json.   You may be getting outdated dependencies. It is recommended that you run `composer update` or `composer update <package name>`.  
       Package operations: 135 installs, 0 updates, 0 removals  
         - Installing kylekatarnls/update-helper (1.2.1): Extracting archive  
         - Installing symfony/polyfill-ctype (v1.26.0): Extracting archive  
         - Installing vlucas/phpdotenv (v2.6.9): Extracting archive  
         - Installing symfony/polyfill-php80 (v1.26.0): Extracting archive  
         - Installing symfony/css-selector (v5.4.11): Extracting archive  
         - Installing tijsverkoyen/css-to-inline-styles (2.2.5): Extracting archive  
         - Installing symfony/polyfill-php72 (v1.26.0): Extracting archive  
         - Installing symfony/polyfill-mbstring (v1.26.0): Extracting archive  
         - Installing symfony/var-dumper (v4.4.46): Extracting archive  
         - Installing symfony/routing (v4.4.44): Extracting archive  
         - Installing symfony/process (v4.4.44): Extracting archive  
         - Installing symfony/polyfill-php73 (v1.26.0): Extracting archive  
         - Installing symfony/polyfill-intl-normalizer (v1.26.0): Extracting archive  
         - Installing symfony/polyfill-intl-idn (v1.26.0): Extracting archive  
         - Installing symfony/deprecation-contracts (v2.5.2): Extracting archive  
         - Installing symfony/mime (v5.4.13): Extracting archive  
         - Installing symfony/http-foundation (v4.4.46): Extracting archive  
         - Installing symfony/http-client-contracts (v2.5.2): Extracting archive  
         - Installing symfony/event-dispatcher-contracts (v1.1.13): Extracting archive  
         - Installing symfony/event-dispatcher (v4.4.44): Extracting archive  
         - Installing psr/log (1.1.4): Extracting archive  
         - Installing symfony/debug (v4.4.44): Extracting archive  
         - Installing symfony/error-handler (v4.4.44): Extracting archive  
         - Installing symfony/http-kernel (v4.4.46): Extracting archive  
         - Installing symfony/finder (v4.4.44): Extracting archive  
         - Installing psr/container (1.1.2): Extracting archive  
         - Installing symfony/service-contracts (v2.5.2): Extracting archive  
         - Installing symfony/console (v4.4.45): Extracting archive  
         - Installing symfony/polyfill-iconv (v1.26.0): Extracting archive  
         - Installing doctrine/lexer (1.2.3): Extracting archive  
         - Installing egulias/email-validator (3.2.1): Extracting archive  
         - Installing swiftmailer/swiftmailer (v6.3.0): Extracting archive  
         - Installing paragonie/random_compat (v9.99.100): Extracting archive  
         - Installing ramsey/uuid (3.9.6): Extracting archive  
         - Installing psr/simple-cache (1.0.1): Extracting archive  
         - Installing opis/closure (3.6.3): Extracting archive  
         - Installing symfony/translation-contracts (v2.5.2): Extracting archive  
         - Installing symfony/translation (v4.4.45): Extracting archive  
         - Installing nesbot/carbon (1.39.1): Extracting archive  
         - Installing monolog/monolog (1.27.1): Extracting archive  
         - Installing league/mime-type-detection (1.11.0): Extracting archive  
         - Installing league/flysystem (1.1.10): Extracting archive  
         - Installing ralouphie/getallheaders (3.0.3): Extracting archive  
         - Installing psr/http-message (1.0.1): Extracting archive  
         - Installing guzzlehttp/psr7 (1.9.0): Extracting archive  
         - Installing guzzlehttp/promises (1.5.2): Extracting archive  
         - Installing guzzlehttp/guzzle (6.5.8): Extracting archive  
         - Installing laravel/slack-notification-channel (v1.0.3): Extracting archive  
         - Installing php-http/promise (1.1.0): Extracting archive  
         - Installing php-http/httplug (v1.1.0): Extracting archive  
         - Installing php-http/guzzle6-adapter (v1.1.1): Extracting archive  
         - Installing psr/http-factory (1.0.1): Extracting archive  
         - Installing zendframework/zend-diactoros (2.2.1): Extracting archive  
         - Installing symfony/http-client (v5.4.13): Extracting archive  
         - Installing lcobucci/jwt (3.4.6): Extracting archive  
         - Installing nexmo/client-core (1.8.1): Extracting archive  
         - Installing nexmo/client (1.9.1): Extracting archive  
         - Installing laravel/nexmo-notification-channel (v1.0.1): Extracting archive  
         - Installing erusev/parsedown (1.7.4): Extracting archive  
         - Installing dragonmantank/cron-expression (v2.3.1): Extracting archive  
         - Installing doctrine/inflector (1.4.4): Extracting archive  
         - Installing laravel/framework (v5.7.29): Extracting archive  
         - Installing firebase/php-jwt (v5.5.1): Extracting archive  
         - Installing auth0/auth0-php (5.7.0): Extracting archive  
         - Installing auth0/login (5.4.0): Extracting archive  
         - Installing automattic/woocommerce (3.1.0): Extracting archive  
         - Installing aws/aws-crt-php (v1.0.2): Extracting archive  
         - Installing mtdowling/jmespath.php (2.6.1): Extracting archive  
         - Installing aws/aws-sdk-php (3.238.1): Extracting archive  
         - Installing aws/aws-sdk-php-resources (0.3.0): Extracting archive  
         - Installing clue/stream-filter (v1.6.0): Extracting archive  
         - Installing symfony/dependency-injection (v4.4.44): Extracting archive  
         - Installing symfony/polyfill-php81 (v1.26.0): Extracting archive  
         - Installing symfony/filesystem (v5.4.13): Extracting archive  
         - Installing symfony/config (v4.4.44): Extracting archive  
         - Installing dzunke/slack-bundle (2.6.0): Extracting archive  
         - Installing easypost/easypost-php (3.6.0): Extracting archive  
         - Installing facebook/graph-sdk (5.7.0): Extracting archive  
         - Installing fideloper/proxy (4.4.2): Extracting archive  
         - Installing gertjanspriensma/etsy-php (dev-master 95f0cb8): Extracting archive  
         - Installing http-interop/http-factory-guzzle (1.2.0): Extracting archive  
         - Installing mmucklo/inflect (v0.3.0): Extracting archive  
         - Installing zendesk/zendesk_api_client_php (v2.2.15): Extracting archive  
         - Installing huddledigital/zendesk-laravel (v3.7): Extracting archive  
         - Installing jakub-onderka/php-console-color (v0.2): Extracting archive  
         - Installing jeremy-dunn/php-fedex-api-wrapper (3.0): Extracting archive  
         - Installing nikic/php-parser (v4.15.1): Extracting archive  
         - Installing jakub-onderka/php-console-highlighter (v0.4): Extracting archive  
         - Installing dnoegel/php-xdg-base-dir (v0.1.1): Extracting archive  
         - Installing psy/psysh (v0.9.12): Extracting archive  
         - Installing laravel/tinker (v1.0.10): Extracting archive  
         - Installing psr/http-client (1.0.1): Extracting archive  
         - Installing markbaker/matrix (3.0.0): Extracting archive  
         - Installing markbaker/complex (3.0.1): Extracting archive  
         - Installing myclabs/php-enum (1.8.4): Extracting archive  
         - Installing maennchen/zipstream-php (2.2.1): Extracting archive  
         - Installing ezyang/htmlpurifier (v4.16.0): Extracting archive  
         - Installing phpoffice/phpspreadsheet (1.25.2): Extracting archive  
         - Installing maatwebsite/excel (3.1.25): Extracting archive  
         - Installing mixpanel/mixpanel-php (2.10.0): Extracting archive  
         - Installing myparcelnl/sdk (v3.1.7): Extracting archive  
         - Installing omnisend/php-sdk (1.2): Extracting archive  
         - Installing paypal/rest-api-sdk-php (1.14.0): Extracting archive  
         - Installing paragonie/constant_time_encoding (v2.6.3): Extracting archive  
         - Installing phpseclib/phpseclib (3.0.16): Extracting archive  
         - Installing php-amqplib/php-amqplib (v3.3.1): Extracting archive  
         - Installing php-http/message-factory (v1.0.2): Extracting archive  
         - Installing phpclassic/php-shopify (v1.2.5): Extracting archive  
         - Installing picqer/sendcloud-php-client (v2.7.0): Extracting archive  
         - Installing symfony/yaml (v4.4.45): Extracting archive  
         - Installing predicthq/address-formatter-templates (v1.0.0): Extracting archive  
         - Installing mustache/mustache (v2.14.2): Extracting archive  
         - Installing predicthq/address-formatter (v1.1.0): Extracting archive  
         - Installing printnode/printnode-php (2.0.0-rc1): Extracting archive  
         - Installing psr/cache (1.0.0): Extracting archive  
         - Installing starkbank/ecdsa (0.0.5): Extracting archive  
         - Installing sendgrid/php-http-client (3.14.4): Extracting archive  
         - Installing sendgrid/sendgrid (7.11.5): Extracting archive  
         - Installing symfony/polyfill-uuid (v1.26.0): Extracting archive  
         - Installing symfony/options-resolver (v5.4.11): Extracting archive  
         - Installing php-http/message (1.13.0): Extracting archive  
         - Installing php-http/discovery (1.14.3): Extracting archive  
         - Installing php-http/client-common (1.11.0): Extracting archive  
         - Installing jean85/pretty-package-versions (2.0.5): Extracting archive  
         - Installing sentry/sentry (2.5.2): Extracting archive  
         - Installing sentry/sdk (2.2.0)  
         - Installing sentry/sentry-laravel (1.9.0): Extracting archive  
         - Installing setasign/fpdi (v2.3.6): Extracting archive  
         - Installing thecodingmachine/safe (v1.3.3): Extracting archive  
         - Installing setono/post-nord-php-sdk (v1.2.0): Extracting archive  
         - Installing graham-campbell/guzzle-factory (v3.0.4): Extracting archive  
         - Installing spatie/dropbox-api (1.21.0): Extracting archive  
         - Installing spatie/laravel-permission (2.38.0): Extracting archive  
         - Installing stripe/stripe-php (v7.128.0): Extracting archive  
         - Installing tecnickcom/tcpdf (6.5.0): Extracting archive  
       Package dzunke/slack-bundle is abandoned, you should avoid using it. No replacement was suggested.  
       Package facebook/graph-sdk is abandoned, you should avoid using it. No replacement was suggested.  
       Package jakub-onderka/php-console-color is abandoned, you should avoid using it. Use php-parallel-lint/php-console-color instead.  
       Package jakub-onderka/php-console-highlighter is abandoned, you should avoid using it. Use php-parallel-lint/php-console-highlighter instead.  
       Package laravel/nexmo-notification-channel is abandoned, you should avoid using it. Use laravel/vonage-notification-channel instead.  
       Package paypal/rest-api-sdk-php is abandoned, you should avoid using it. No replacement was suggested.  
       Package predicthq/address-formatter is abandoned, you should avoid using it. No replacement was suggested.  
       Package predicthq/address-formatter-templates is abandoned, you should avoid using it. No replacement was suggested.  
       Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.  
       Package symfony/debug is abandoned, you should avoid using it. Use symfony/error-handler instead.  
       Package zendframework/zend-diactoros is abandoned, you should avoid using it. Use laminas/laminas-diactoros instead.  
       Package fzaninotto/faker is abandoned, you should avoid using it. No replacement was suggested.  
       Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested.  
       Generating optimized autoload files  
       Class FedEx\Tests\ValidationAvailabilityAndCommitmentService located in ./vendor/jeremy-dunn/php-fedex-api-wrapper/tests/FedEx/Tests/ValidationAvailabilityAndCommitmentServiceTest.php does not comply with psr-4 autoloading standard. Skipping.  
       > Illuminate\Foundation\ComposerScripts::postAutoloadDump  
       61 packages you are using are looking for funding.  
       Use the `composer fund` command to find out more!  
-----> Preparing runtime environment...  
-----> Checking for additional extensions to install...  
-----> Potrace loaded app detected  
-----> Installing potrace  
potrace-1.16.linux-x86_64/  
potrace-1.16.linux-x86_64/README-WIN  
potrace-1.16.linux-x86_64/potrace.1  
potrace-1.16.linux-x86_64/placement.pdf  
potrace-1.16.linux-x86_64/README  
potrace-1.16.linux-x86_64/NEWS  
potrace-1.16.linux-x86_64/ChangeLog  
potrace-1.16.linux-x86_64/mkbitmap.1  
potrace-1.16.linux-x86_64/mkbitmap  
potrace-1.16.linux-x86_64/AUTHORS  
potrace-1.16.linux-x86_64/potrace  
potrace-1.16.linux-x86_64/COPYING  
-----> Discovering process types  
       Procfile declares types -> web, worker  
-----> Compressing...  
       Done: 186.1M  
-----> Launching...  
       Released v318  
       https://my-app.herokuapp.com/ deployed to Heroku  
This app is using the Heroku-20 stack, however a newer stack is available.  
To upgrade to Heroku-22, see:  
https://devcenter.heroku.com/articles/upgrading-to-the-latest-stack


via Chebli Mohamed

jeudi 5 octobre 2023

After change the password login is not working using Laravel

I created the client register and the password change function. When I register the client with the password that password and username are working without any issues. But when I change the password and log in with a new password always says the password is incorrect.I can't understand what is the issue please help me to solve this issue.

This is my register code

public function store(Request $request, client $client)
    {
        
        $token = $request->input('g-recaptcha-response');

        if(strlen($token)>0)
        {
        
            $result = client::where('email', $request->email)->first();
    
            if (!empty($result))
            {
                return Redirect::back()->with('errmessage','The registered email address is already in use. Please contact the website administrator or request a password reset');
            }
    
            $client->clie_id = $request->email;
            $client->clie_fname = $request->clie_fname;
            $client->clie_lname = $request->clie_lname;
            $client->clie_company = $request->clie_company;
            $client->password = Hash::make($request->password);
            $client->email = $request->email;
            $client->clie_telephone = $request->clie_telephone;
            $client->clie_fax = $request->clie_fax;
            $client->clie_address1 = $request->clie_address1;
            $client->clie_address2 = $request->clie_address2;
            $client->clie_address3 = $request->clie_address3;
    
            $client->clie_city = $request->clie_city;
            $client->clie_state = $request->clie_state;
            $client->clie_postcode = $request->clie_postcode;
            $client->clie_country = $request->clie_country;
    
            $client->clie_newslatter= $request->clie_newslatter;
    
            $client->save();
    
            return Redirect::back()->with('message','Account Created Successfully. You may now login using the email you registered with and your password');
            
        }else{
            return redirect()->back()->with('warmessage','Please make sure your not a robot');
        }
    }

This is my password change function

public function PasswordChange(Request $request)
    {
        
        //dd($request->clientId);
        
        $token = $request->input('g-recaptcha-response');

        if(strlen($token)>0)
        {
            $user = Client::where('email', $request->clientId)->first();

            if (!$user) {
                return redirect()->back()->with('error', 'User not found.');
            }
            
            if (!Hash::check($request->old_password, $user->password)) {
                return redirect()->back()->with('error', 'The old password is incorrect.');
            }
            
            $user->update([
                'password' => Hash::make($request->password)
            ]);
            
            // Clear the user's session to ensure the new password takes effect
            Auth::guard('client')->logout();
        
            return redirect()->route('Home')->with('message','Password is Successfully changed.');
            
        }else{
            return redirect()->back()->with('message','Please make sure your not a robot');
        }

        // return redirect()->route('home')->with('success', 'Password changed successfully.');
    }

My login function

public function login(Request $request)
    {
        
        //dd($request->password);
        
        // Retrieve the user record by email
        $user = client::where('email', $request->email)->first();
        
        Log::info('Login attempt:', [
            'email' => $request->email,
            'entered_org_password' => $request->password,
            'entered_password' => Hash::make($request->password),
            'hashed_password' => $user->password,
        ]);
        

        if(Auth::guard('client')->attempt(['email'=>$request->email,'password'=>$request->password],$request->remember))
        {
          return redirect('/')->withMessage('Successfully Logged In');
        }else{
            return redirect(route('Client_Login'))->with('Error');
        }

        return redirect()->back()->withInput($request->only('email'));
    }

This is my log data when login with a new password

After Registering this the records for login.

[2023-10-05 08:34:06] local.INFO: Login attempt: {"email":"james@gmail.com","entered_org_password":"123456789","entered_password":"$2y$10$1mR2dKLEJAHvv0BCQoCfZeLP5Ugq4ngTvHD4/RFDtXp.asB7AJKF.","hashed_password":"$2y$10$Jxm/cd25Xpe4i8ljfDV98uIICszGb61pV6PtcwuhqHayjujWsOejm"} 

After changing the password and login records

[2023-10-05 08:35:21] local.INFO: Login attempt: {"email":"james@gmail.com","entered_org_password":"123456789123","entered_password":"$2y$10$49D4RS5aNWwl8xtnWOGeQ.wuT2Ozipz4O1yAtmJQAsmjoZiLQb3b.","hashed_password":"$2y$10$.dj8Egmzr0JDs7IlmMfZ2ultD5Srp5YTo0Wxi0WHmxscc0P1cpS3u"} 


via Chebli Mohamed

How to update 5000+ records in a set of 200s in laravel?

I have a total of approximately 8000+ records. I want to update them in a set of 200s, so that the site which I am working on, doesn't go down due to excessive queries execution. Right now I am not able to do that.

This is my code:

$totalRecords = DB::table('domain_authority_score_update')->where('update_flag', 0);
$reduceRecords = $totalRecords->take(200)->get();

I have used foreach to update all records.

foreach($reduceRecords as $val){
}

I have tried to update them by using for() loop and also do-while() loop, but it didn't give me the expected result.

I have also tried using chunk(). But I did not succeed.

Any help would be appreciated. Thanks in advance.



via Chebli Mohamed

mercredi 4 octobre 2023

Laravel Post & Comments relation, only post author can delete the comment. but the user who made comment can edit and delete also

I don't have any idea how to do it. if anybody knows about it. let me know. I think its some thing relevant to validation. plz guide me.

only post author can delete the comment. but the user who made comment can edit and delete also



via Chebli Mohamed