Skip to content

Full Stack Programmer

Just another blog classic, isn't it!

Full Stack Programmer

Just another blog classic, isn't it!

  • Blog
  • Who am i?
  • More About Me
    • Skills
    • Experience
    • Recommendations
    • Education
    • My Activities
  • IT Services
  • #Instagram
  • Contact
  • Privacy & Policy
Laravel

Laravel: Login with email or phone

 Danyal  March 18, 2021  Posted in Code snippets, Laravel, PHP, Programming Tagged Authentication, LaravelPassport, login
public function login(Request $request)
{
    $user = User::where('email', $request->emailOrPhone)
                    ->orWhere('phone', $request->emailOrPhone)
                    ->first();
    if($user){
        if (Hash::check($request->password, $user->password)) {

            $tokenResult = $user->createToken('Personal Access Token');
            $token = $tokenResult->token;
            if ($request->remember_me)
                $token->expires_at = Carbon::now()->addWeeks(1);
            $token->save();
            return response()->json([
                'access_token' => $tokenResult->accessToken,
                'expires_at' => Carbon::parse(
                    $tokenResult->token->expires_at
                )->toDateTimeString()
            ]);

        } else {
            $response = ['Password incorrect'];
            return response($response, 422);
        }
    }else {
        $response = ['User does not exist'];
        return response($response, 422);
    }

}
Post Views: 4,177
Author: Danyal
I'm a skilled programmer specializing in Vue.js/Nuxt.js for front-end development and PHP Laravel for back-end solutions. I have a strong focus on API design and development, complemented by experience in web server setup and maintenance. My versatile expertise ensures seamless creation and maintenance of web applications, covering everything from intuitive user interfaces to robust server-side functionality. Passionate about coding and driven by a lifelong learning mindset, I invite you to explore more at danyal.dk.

Post navigation

Build issue with Xcode 12.3 – file not found #include “ruby/config.h” →
← Drupal: How to enable HTTPS support in Drupal

Posts

  • How to Install Jenkins Locally on a MacBook (Step-by-Step Guide) May 17, 2025
  • How Safe Are UUIDs for User Identification in JavaScript? April 21, 2025
  • ๐—ฆ๐˜๐—ผ๐—ฝ ๐—จ๐˜€๐—ถ๐—ป๐—ด c๐—ผ๐—ป๐˜€๐—ผ๐—น๐—ฒ.๐—น๐—ผ๐—ด() ๐—ณ๐—ผ๐—ฟ ๐——๐—ฒ๐—ฏ๐˜‚๐—ด๐—ด๐—ถ๐—ป๐—ด, instead use c๐—ผ๐—ป๐˜€๐—ผ๐—น๐—ฒ.table() November 29, 2024
  • M๐—ผ๐—ป๐—ผ๐—น๐—ถ๐˜๐—ต ๐˜๐—ผ ๐— ๐—ถ๐—ฐ๐—ฟ๐—ผ๐˜€๐—ฒ๐—ฟ๐˜ƒ๐—ถ๐—ฐ๐—ฒ๐˜€: ๐—” ๐—ฃ๐—ฎ๐˜๐—ต ๐˜๐—ผ ๐—ฆ๐—ฐ๐—ฎ๐—น๐—ฎ๐—ฏ๐—ถ๐—น๐—ถ๐˜๐˜†! November 28, 2024
  • Sort Categories by Count in WPGraphQL November 24, 2024

Advertisement

Tags

array (3) Authentication (6) build (3) coding (8) commands (6) composer (4) database (5) devops (5) docker (3) drupal (5) Eloquent (3) error (5) Git (3) GraphQL (3) help (3) ios (5) javascript (17) jQuery (3) js (5) laravel (22) Laravel 5.6 (6) laravel5.7 (4) LaravelPassport (3) linux (7) lumen (7) LumenPassport (3) microbit (3) migration (3) mysql (8) network (3) node (3) php (25) python (6) security (3) SQL (3) ssh (3) SSL (3) technology (7) tip of the day (3) tips (7) ubuntu (8) ultrabit (3) upgrade (3) vuejs (13) vuex (3)

Advertisement

Categories

  • Apache2 (1)
  • Chrome (1)
  • CI/CD (1)
  • CkEditor (1)
  • Cloud (2)
  • CMS (8)
  • Code Editors (1)
  • Code snippets (1)
  • Composer (1)
  • Daily Tips (5)
  • Databases (5)
  • Development (5)
  • Docker (4)
  • Eloquent (1)
  • EU (1)
  • File System (1)
  • Git (3)
  • Google (2)
  • GraphQL (2)
  • Gulp (1)
  • Heandy Tips (2)
  • HTML (1)
  • javascript (21)
  • Laravel (32)
  • Laravel 5.5 (8)
  • Linux (10)
  • Lumen (6)
  • Microbit (4)
  • MySQL (5)
  • News & Updates (5)
  • Nginx (2)
  • Node (1)
  • Nuxt.js (3)
  • osMac (3)
  • Package Managers (1)
  • PHP (29)
  • Programming (8)
  • Python (2)
  • Ruby on Rails (1)
  • Support (1)
  • Symfony (3)
  • Tips (7)
  • Tools (1)
  • Ubuntu (11)
  • Ubuntu 16.04 (10)
  • Ubuntu 17 (6)
  • Uncategorized (8)
  • Vlog (1)
  • Vuejs (11)
  • Wordpress (1)
  • xcode (3)

Recent Posts

  • How to Install Jenkins Locally on a MacBook (Step-by-Step Guide)
  • How Safe Are UUIDs for User Identification in JavaScript?
  • ๐—ฆ๐˜๐—ผ๐—ฝ ๐—จ๐˜€๐—ถ๐—ป๐—ด c๐—ผ๐—ป๐˜€๐—ผ๐—น๐—ฒ.๐—น๐—ผ๐—ด() ๐—ณ๐—ผ๐—ฟ ๐——๐—ฒ๐—ฏ๐˜‚๐—ด๐—ด๐—ถ๐—ป๐—ด, instead use c๐—ผ๐—ป๐˜€๐—ผ๐—น๐—ฒ.table()
  • M๐—ผ๐—ป๐—ผ๐—น๐—ถ๐˜๐—ต ๐˜๐—ผ ๐— ๐—ถ๐—ฐ๐—ฟ๐—ผ๐˜€๐—ฒ๐—ฟ๐˜ƒ๐—ถ๐—ฐ๐—ฒ๐˜€: ๐—” ๐—ฃ๐—ฎ๐˜๐—ต ๐˜๐—ผ ๐—ฆ๐—ฐ๐—ฎ๐—น๐—ฎ๐—ฏ๐—ถ๐—น๐—ถ๐˜๐˜†!

Tags

array (3) Authentication (6) build (3) coding (8) commands (6) composer (4) database (5) devops (5) docker (3) drupal (5) Eloquent (3) error (5) Git (3) GraphQL (3) help (3) ios (5) javascript (17) jQuery (3) js (5) laravel (22) Laravel 5.6 (6) laravel5.7 (4) LaravelPassport (3) linux (7) lumen (7) LumenPassport (3) microbit (3) migration (3) mysql (8) network (3) node (3) php (25) python (6) security (3) SQL (3) ssh (3) SSL (3) technology (7) tip of the day (3) tips (7) ubuntu (8) ultrabit (3) upgrade (3) vuejs (13) vuex (3)

RSS Rida.dk

  • The Berlin Wall
  • Turkey: one of top 10 most visited countries #6
  • Italy: one of top 10 most visited countries #5
  • Daily Motivation #3
  • Daily Motivation #2
  • Daily Motivation #1
  • China: one of top 10 most visited countries #4
  • USA: one of top 10 most visited countries #3
  • Spain: one of top 10 most visited countries #2
  • France: one of top 10 most visited countries #1

RSS Abdulraheem.dk

  • Facts about Lotte world tower
  • Facts About Pingย An Finance Tower
  • Facts about Abraj Al-Bait
  • Facts about Shanghai tower
  • Facts about Merdeka 118
  • Facts about Brandenburg gate
  • Facts about the Berliner Fernsehturm
  • Top ten tallest buildings in the world
  • Facts about Lego House Billund
  • Facts about Universe science park

RSS Laravel News

  • Add QR Code field functionality to your Filament UI's
  • Convert Eloquent Models to HLS Video
  • Early View Data Preparation with Laravel View Creators
  • Laravel's toUri() Method for Dynamic URL Construction
  • AI-Driven Development Insiders Launch: 500 Seats. 24 Hours. 50% Off

RSS Python Insider

  • Python 3.14.0 beta 4 is here!
  • Python 3.14.0 beta 3 is here!
  • Python 3.13.5 is now available!
  • Python 3.13.4, 3.12.11, 3.11.13, 3.10.18 and 3.9.23 are now available
  • Python 3.14.0 beta 2 is here!
  • Python 3.14.0 beta 1 is here!
  • Python 3.14.0a7, 3.13.3, 3.12.10, 3.11.12, 3.10.17 and 3.9.22 are now available
  • Python 3.14.0 alpha 6 is out
  • Python 3.14.0 alpha 5 is out
  • Python 3.13.2 and 3.12.9 now available!

RSS Abdulsamad.dk

  • Facts about Rundetรฅrnet
  • Scratch 3.0 Cat Color Art โ€“ Project1
  • digt om en bรฅndegรฅrd
  • Fakta om Monkey land Hillerรธd
  • Fakta om Universe science park
  • Digt
  • Fakta Ankylosaurer
  • Learn facts about eiffel tower
  • Digt om kedsomhed
  • digt om kรฆrlighed

We runs on green energy!

This website is hosted Green - checked by thegreenwebfoundation.org

Copyright © 2025 Full Stack Programmer

Design by ThemesDNA.com

Verified by ExactMetrics