Skip to content

Full Stack Programmer

Need a website, web app or API?

Full Stack Programmer

Need a website, web app or API?

  • 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: 3,057
Author: Danyal
I'm working as programmer since 2002. Born, grew up, studied and worked in Pakistan now Im located in Denmark since 2006.

Post navigation

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

Posts

  • Vuejs: Lifecycle Hooks May 12, 2022
  • Auth: Cannot read property ‘$cookies’ of undefined  April 6, 2022
  • Linux GNU Screen March 13, 2022
  • Local Privilege Escalation Vulnerability in all major Linux distributions January 26, 2022
  • How to run NUXTJS development env with HTTPS in localhost? December 23, 2021
Backend Skills
Website & Web App Development
PHP Slim, Symfony 3.4, Laravel 5.8 & Lumen 5.8
MVC Applications and RestAPI's Development (PHP 5.6 & PHP 7)
MySQL, MongoDB, PostgresQL
Apache2, Nginx, Caching & Cloud Server Management
Frontend Skills
Javascript, jQuery, AngularJS, CSS3, HTML5, Bootstrap4
Bootstrap4 templating custom SCSS
Nuxtjs & Vuejs
Using in Bold.dk new version and other freelance projects.
Systems & Tools
E-Mail & SMS Marketing & Customer Satisfaction Surveys
SurveyGizmo, eMailPlatform
danyal.dk

Other Posts

  • Vuejs: Lifecycle Hooks May 12, 2022
  • Auth: Cannot read property ‘$cookies’ of undefined  April 6, 2022
  • Linux GNU Screen March 13, 2022
  • Local Privilege Escalation Vulnerability in all major Linux distributions January 26, 2022
  • How to run NUXTJS development env with HTTPS in localhost? December 23, 2021

Advertisement

Tags

.htaccess (2) Authentication (6) coding (5) commands (6) composer (4) database (4) devops (5) DigitalOcean (2) docker (3) drupal (5) Eloquent (3) error (5) Git (3) help (3) javascript (11) jQuery (3) js (3) laravel (17) laravel 5.5 (2) Laravel 5.6 (6) laravel5.7 (4) LaravelPassport (3) linux (7) lumen (7) LumenPassport (3) migration (3) mysql (6) network (2) node (3) permissions (2) php (16) production (2) python (5) ssh (3) SSL (3) Symfony (2) Symfony 4 (2) technology (6) tip of the day (3) tips (6) ubuntu (8) Ubuntu 16.04 (2) Ubuntu 17 (2) upgrade (3) vuejs (10)

Advertisement

Backend Skills
Website & Web App Development
PHP Slim, Symfony 3.4, Laravel 5.8 & Lumen 5.8
MVC Applications and RestAPI's Development (PHP 5.6 & PHP 7)
MySQL, MongoDB, PostgresQL
Apache2, Nginx, Caching & Cloud Server Management
Frontend Skills
Javascript, jQuery, AngularJS, CSS3, HTML5, Bootstrap4
Bootstrap4 templating custom SCSS
Nuxtjs & Vuejs
Using in Bold.dk new version and other freelance projects.
Systems & Tools
E-Mail & SMS Marketing & Customer Satisfaction Surveys
SurveyGizmo, eMailPlatform

Recent Posts

  • Vuejs: Lifecycle Hooks
  • Auth: Cannot read property ‘$cookies’ of undefined 
  • Linux GNU Screen
  • Local Privilege Escalation Vulnerability in all major Linux distributions
  • How to run NUXTJS development env with HTTPS in localhost?
Backend Skills
Website & Web App Development
PHP Slim, Symfony 3.4, Laravel 5.8 & Lumen 5.8
MVC Applications and RestAPI's Development (PHP 5.6 & PHP 7)
MySQL, MongoDB, PostgresQL
Apache2, Nginx, Caching & Cloud Server Management
Frontend Skills
Javascript, jQuery, AngularJS, CSS3, HTML5, Bootstrap4
Bootstrap4 templating custom SCSS
Nuxtjs & Vuejs
Using in Bold.dk new version and other freelance projects.
Systems & Tools
E-Mail & SMS Marketing & Customer Satisfaction Surveys
SurveyGizmo, eMailPlatform

Tags

.htaccess (2) Authentication (6) coding (5) commands (6) composer (4) database (4) devops (5) DigitalOcean (2) docker (3) drupal (5) Eloquent (3) error (5) Git (3) help (3) javascript (11) jQuery (3) js (3) laravel (17) laravel 5.5 (2) Laravel 5.6 (6) laravel5.7 (4) LaravelPassport (3) linux (7) lumen (7) LumenPassport (3) migration (3) mysql (6) network (2) node (3) permissions (2) php (16) production (2) python (5) ssh (3) SSL (3) Symfony (2) Symfony 4 (2) technology (6) tip of the day (3) tips (6) ubuntu (8) Ubuntu 16.04 (2) Ubuntu 17 (2) upgrade (3) vuejs (10)

Recent Posts

  • Vuejs: Lifecycle Hooks
  • Auth: Cannot read property ‘$cookies’ of undefined 
  • Linux GNU Screen
  • Local Privilege Escalation Vulnerability in all major Linux distributions
  • How to run NUXTJS development env with HTTPS in localhost?

Most Viewed Posts

  • Laravel 5.7 Route [login] not defined (14,083)
  • Install Laravel required PHP & Extentions (11,331)
  • Laravel composer install – Your requirements could not be resolved to an installable set of packages. (11,017)
  • Dual boot windows 10 & Ubuntu 16.04 – Lenovo Y520 (8,878)
  • Vue Loading overlay component (8,483)

RSS Rida.dk

  • 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

RSS Abdulraheem.dk

  • Quiz about The National Rifle Association (NRA)
  • Facts about London Eye
  • Burj Khalifa
  • Control led lights with BBC Micro:bit (fun & code)
  • DR Ultra:bit Start Kit (fun & code)
  • Kangaroo Island
  • Volvo Museum (Sweden – Göteborg)
  • The National Rifle Association (NRA)

RSS Abdulsamad.dk

  • Fakta om en kat. på Dansk
  • Fakta om Gorilla På dansk
  • Flagermus/Bats
  • Code Polar Bear – Scratch
  • My first project
  • Megabots Nr.5
  • Megabots Nr.2
  • Days of the week

RSS Laravel News

  • How to Validate Your Laravel App's Config
  • Laravel 9.13 Released
  • Eloquent Performance: 4 Examples of N+1 Query Problems
  • Laravel Roles and Permissions: Gates and Policies Explained
  • Livewire or Inertia.js?

RSS Python Insider

  • Python 3.9.13 is now available
  • Python 3.11.0b1 is now available
  • The last Python 3.11 alpha (3.11.0a7) is available
  • Python 3.10.4 and 3.9.12 are now available out of schedule
  • Python 3.10.3, 3.9.11, 3.8.13, and 3.7.13 are now available with security content

Tags

.htaccess Authentication coding commands composer database devops DigitalOcean docker drupal Eloquent error Git help javascript jQuery js laravel laravel 5.5 Laravel 5.6 laravel5.7 LaravelPassport linux lumen LumenPassport migration mysql network node permissions php production python ssh SSL Symfony Symfony 4 technology tip of the day tips ubuntu Ubuntu 16.04 Ubuntu 17 upgrade vuejs

Copyright © 2022 Full Stack Programmer

Design by ThemesDNA.com