Adgower

Adgower

Member Since 4 Months Ago

Oklahoma City

Experience Points
20,720
Total
Experience

4,280 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
194
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 5
20,720 XP
Oct
25
3 days ago
Activity icon

Awarded Best Reply on Http Client & Paypal API Invalid Request

Had to add application_context (even though it says its not required...)

Http::withToken($response->json()['access_token'])->post('https://api.sandbox.paypal.com/v2/checkout/orders/'.$request->token.'/capture',[
            'application_context' => [
                'return_url' => route('invoices.index'),
                'cancel_url' => route('payments.cancel')
            ]
        ]);

https://developer.paypal.com/docs/api/orders/v2/#definition-order_capture_request.customized_x_unsupported_3218_order_application_context

Activity icon

Replied to Http Client & Paypal API Invalid Request

Had to add application_context (even though it says its not required...)

Http::withToken($response->json()['access_token'])->post('https://api.sandbox.paypal.com/v2/checkout/orders/'.$request->token.'/capture',[
            'application_context' => [
                'return_url' => route('invoices.index'),
                'cancel_url' => route('payments.cancel')
            ]
        ]);

https://developer.paypal.com/docs/api/orders/v2/#definition-order_capture_request.customized_x_unsupported_3218_order_application_context

Activity icon

Replied to Advanced Query Help

Post models and tables

Possible Models:

Facility: Methods(techs(), files('fileable'))
Tech: Methods(facility(), files()) //table has(facility_id)
File: Methods(facilities(), techs()) //table has(morph(fileable(example: 'App\Models\Facility' or 'App\Models\Tech'), uploader_id/user_id/tech_id))

Then you can pull the data a few different ways:

$facility = Facility::find(id);
$facility->files _> foreach(file $file->tech/uploader_id)
$facility->techs _> foreah(tech $files->if(matches facility id))
Activity icon

Started a new Conversation Http Client & Paypal API Invalid Request

I can't capture this payment does anyone have any tips point me in the right direction? I think I'm missing something from the body of the request, but I have all the required, according to the API documentation. Was wondering if its a Http client issue?

Http::withToken($response->json()['access_token'])->post('https://api.sandbox.paypal.com/v2/checkout/orders/'.$request->token.'/capture');
{"name":"INVALID_REQUEST","message":"Request is not well-formed, syntactically incorrect, or violates schema.","debug_id":"1ba98921ebb38","details":[{"field":"\/","location":"body","issue":"INVALID_SYNTAX","description":"MALFORMED_REQUEST_JSON"}],"links":[{"href":"https:\/\/developer.paypal.com\/docs\/api\/orders\/v2\/#error-INVALID_SYNTAX","rel":"information_link","encType":"application\/json"}]}
Oct
20
1 week ago
Activity icon

Replied to Query Polymorphic Relationship

@sinnbeck User Model

public function invoices()
    {
        return $this->morphMany('App\Models\Invoice', 'billable');
    }

Invoice Model

public function billable()
    {
        return $this->morphTo();
    }
Activity icon

Started a new Conversation Query Polymorphic Relationship

I have a students page with where each student has an invoice for the course, and i want to check the status of each invoice (paid/unpaid) for each student.

$event->invoices->where('paid', false)->where('billable_id', $student->id)

That retrieves it fine, but this is a polymorphic relationship so sometimes the billable_id might reference another model. How can I search through only users.

Point me in the right direction! Thanks

Oct
18
1 week ago
Activity icon

Started a new Conversation Many To Many Polymorphic

I have the following: Events are schedulable and can have courses OR services. This works fine I can attach multiple courses OR services per event, but if the event is for a course then there is actually only ever 1 course. So instead of return a collection how can I either save just 1 course or have it return without having to:

$event->courses->first()->name;

rather

$event->course->name;

Also thought about also putting another morph directly on the event table, but then this over complicates the goal. I think...

If you have tips to point me in the right direction I would appreciate it. I'm not entirely sure about the best way to go about this.

Thanks

Oct
15
1 week ago
Activity icon

Started a new Conversation Alisa Not Working

I'm trying to use an alias for the Mula Pkg https://github.com/lukeraymonddowning/mula

config/app.php

'Mula' => Lukeraymonddowning\Mula\Facades\Mula::class
composer dump-autoload
php artisan config:clear
php artisan config:cache

I can get it to work in blade if I use

{{Lukeraymonddowning\Mula\Facades\Mula::create($topic->price, 'USD')}}

but I just want to ref

Mula::create($topic->price, 'USD')

Can anyone point me in the right direction?

Sep
29
4 weeks ago
Activity icon

Awarded Best Reply on Algolia Installation Failed

I had to install specific version for php 7.4

sudo apt-get install php7.4-curl
Activity icon

Replied to Algolia Installation Failed

I had to install specific version for php 7.4

sudo apt-get install php7.4-curl
Activity icon

Started a new Conversation Algolia Installation Failed

I am following the documentation on laravel 8.x website for scout and when I run:

composer require algolia/algoliasearch-client-php

it says

Using version ^2.7 for algolia/algoliasearch-client-php
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for algolia/algoliasearch-client-php ^2.7 -> satisfiable by algolia/algoliasearch-client-php[2.7.0].
    - algolia/algoliasearch-client-php 2.7.0 requires ext-curl * -> the requested PHP extension curl is missing from your system.

  To enable extensions, verify that they are enabled in your .ini files:
    - /etc/php/7.4/cli/php.ini
    - /etc/php/7.4/cli/conf.d/10-mysqlnd.ini
    - /etc/php/7.4/cli/conf.d/10-opcache.ini
    - /etc/php/7.4/cli/conf.d/10-pdo.ini
    - /etc/php/7.4/cli/conf.d/15-xml.ini
    - /etc/php/7.4/cli/conf.d/20-bcmath.ini
    - /etc/php/7.4/cli/conf.d/20-calendar.ini
    - /etc/php/7.4/cli/conf.d/20-ctype.ini
    - /etc/php/7.4/cli/conf.d/20-dom.ini
    - /etc/php/7.4/cli/conf.d/20-exif.ini
    - /etc/php/7.4/cli/conf.d/20-ffi.ini
    - /etc/php/7.4/cli/conf.d/20-fileinfo.ini
    - /etc/php/7.4/cli/conf.d/20-ftp.ini
    - /etc/php/7.4/cli/conf.d/20-gd.ini
    - /etc/php/7.4/cli/conf.d/20-gettext.ini
    - /etc/php/7.4/cli/conf.d/20-iconv.ini
    - /etc/php/7.4/cli/conf.d/20-json.ini
    - /etc/php/7.4/cli/conf.d/20-mbstring.ini
    - /etc/php/7.4/cli/conf.d/20-mysqli.ini
    - /etc/php/7.4/cli/conf.d/20-pdo_mysql.ini
    - /etc/php/7.4/cli/conf.d/20-phar.ini
    - /etc/php/7.4/cli/conf.d/20-posix.ini
    - /etc/php/7.4/cli/conf.d/20-readline.ini
    - /etc/php/7.4/cli/conf.d/20-shmop.ini
    - /etc/php/7.4/cli/conf.d/20-simplexml.ini
    - /etc/php/7.4/cli/conf.d/20-sockets.ini
    - /etc/php/7.4/cli/conf.d/20-sysvmsg.ini
    - /etc/php/7.4/cli/conf.d/20-sysvsem.ini
    - /etc/php/7.4/cli/conf.d/20-sysvshm.ini
    - /etc/php/7.4/cli/conf.d/20-tokenizer.ini
    - /etc/php/7.4/cli/conf.d/20-xmlreader.ini
    - /etc/php/7.4/cli/conf.d/20-xmlwriter.ini
    - /etc/php/7.4/cli/conf.d/20-xsl.ini
  You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

Installation failed, reverting ./composer.json to its original content.

I then check curl

dpkg -l curl

returns

Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version           Architecture Description
+++-==============-=================-============-======================================>
ii  curl           7.68.0-1ubuntu2.2 amd64        command line tool for transferring dat>

I'm running nginx ubuntu 20.04

Any tips?

Activity icon

Awarded Best Reply on Installing Scout

needed to change

/

to

\
Activity icon

Replied to Installing Scout

needed to change

/

to

\
Activity icon

Started a new Conversation Installing Scout

I'm trying to install scout using the documentation, but I get this error:

Unable to locate publishable resources.
Publishing complete.

When I run:

php artisan vendor:publish --provider="Laravel/Scout/ScoutServiceProvider"
Aug
28
2 months ago
Activity icon

Replied to How To Sum Polymorphic Through Relationship

@sinnbeck The first one returns

"20.00"

The second one returns

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'services.price' in 'field list' (SQL: select sum(`services`.`price`) as aggregate from `events`)

Yes I want to get the total sum of the prices for all the services for each event attached to the invoice.

Activity icon

Started a new Conversation How To Sum Polymorphic Through Relationship

Hey not sure if the question is right, but I have:

$invoices->first()->events()->first()->services->first()->price;

I would like to sum the total price (something like this, if invoice has 2 events attached):

$invoices->first()->events->sum('services.price');

Can someone point me in the right direction?

Thanks, Alex

Aug
17
2 months ago
Activity icon

Awarded Best Reply on How To Query Polymorphic Relationship

Got it thanks!

$events = Event::has('courses')->with('courses')->whereHas('courses', function ($query) use ($course) {
            $query->where('id', $course->id);
        })->get();
Activity icon

Replied to How To Query Polymorphic Relationship

Got it thanks!

$events = Event::has('courses')->with('courses')->whereHas('courses', function ($query) use ($course) {
            $query->where('id', $course->id);
        })->get();
Activity icon

Started a new Conversation How To Query Polymorphic Relationship

I'm trying to select an event that is a "course" where the course is a certain course.

$events = Event::has('courses')->with('courses')->where('schedulables.scheduleable_id', $course->id)->get();

Could someone point me in the right direction?

Thanks, Alex

Aug
13
2 months ago
Activity icon

Replied to Best Way To Convert This String To Time?

Thanks guys I got it. I had the create from Format wrong... should have been m-d-Y based upon input.

Activity icon

Replied to Best Way To Convert This String To Time?

@snapey thank you very helpful information, but its still returning 2021 instead of 2020 as the year and the month and day are wrong based upon the input

return Carbon::createFromFormat('d-m-Y H:i', $request->appointment_date . ' ' . $time)->format('Y-m-d h:i:s');

returns

2021-06-08 02:00:00
Activity icon

Replied to Best Way To Convert This String To Time?

@sinnbeck

Thank you.

I have this so far:

$hour = Str::of($request->appointment_time)->substr(0, 2);
        $hourConverted = $hour;

        if (strval($hour) >= 1 && strval($hour) <= 5) {
            $hourConverted = strval($hour) + 12;
        }

        $time = $hourConverted . Str::of($request->appointment_time)->substr(2, 3);

        return Carbon::createFromFormat('d-m-Y H:i', $request->appointment_date . ' ' . $time);

appointment_time = 02:00 appointment_date = 08-18-2020

returns:

"2021-06-08T14:00:00.000000Z"

This is wrong. Have any tips?

Activity icon

Started a new Conversation Best Way To Convert This String To Time?

I need to convert these strings into a start_date and end_date I get the duration in minutes, date, and time.

Example:

$duration = 60;
$date = 08/13/2020;
$time = 2:00; // PM

I can

return Carbon::createFromFormat('d-m-Y', $date);

I need the final output:

$start_date and $end_date format: YYYY-MM-DD HH:MI:SS with the difference between the two using the duration.

Thanks

Jul
31
2 months ago
Activity icon

Replied to Generate Dynamic Routes, But Keep Auth

@michaloravec the logout route doesn't work for some reason. The issue is: If I click logout button it works, but if I just type /logout it doesn't work. I assume because it is not submitting that POST request to logout. Any tips? I think it's all good.

Jul
30
2 months ago
Activity icon

Replied to Generate Dynamic Routes, But Keep Auth

Auth::routes();

Route::middleware('auth')->prefix('admin')->group(function () {
    Route::get('/', '[email protected]')->name('dashboard');

    Route::resource('appointments', 'AppointmentController');
    Route::resource('companies', 'CompanyController');
});

Route::get('/{page}', '[email protected]');
Activity icon

Started a new Conversation Generate Dynamic Routes, But Keep Auth

Hey can someone point me in the right direction? I want to be able to use dynamic slugs for a pagemanager concept, but when I setup the routes for it. It breaks the auth routes. What is the best way to do this?

Jul
23
3 months ago
Activity icon

Awarded Best Reply on How To Query Users Company Id On Event?

This works, but is there a more efficient way?

$company = Company::whereHas('user', function ($query) {
                $query->where('user_id', Auth::id());
            })->first();

            $course_events = Event::has('courses')->whereHas('users.companies', function ($query) use ($company) {
                $query->where('company_id', $company->id);
            });

            $events = Event::has('services')->whereHas('user.companies', function ($query) use ($company) {
                $query->where('company_id', $company->id);
            })->union($course_events)->where('start_date', '>=', Carbon::now('America/Chicago'))->orderBy('start_date', 'asc')->get();
Jul
21
3 months ago
Activity icon

Replied to How To Query Users Company Id On Event?

This works, but is there a more efficient way?

$company = Company::whereHas('user', function ($query) {
                $query->where('user_id', Auth::id());
            })->first();

            $course_events = Event::has('courses')->whereHas('users.companies', function ($query) use ($company) {
                $query->where('company_id', $company->id);
            });

            $events = Event::has('services')->whereHas('user.companies', function ($query) use ($company) {
                $query->where('company_id', $company->id);
            })->union($course_events)->where('start_date', '>=', Carbon::now('America/Chicago'))->orderBy('start_date', 'asc')->get();
Jul
20
3 months ago
Activity icon

Started a new Conversation How To Query Users Company Id On Event?

I have a company owner role for users. I want to display the companies users events/appointments to the company owner role. Events can have a user_id, and then another type of event has many users for the event.

How can I make this concept in eloquent:

if (Auth::user()->hasRole('company')) {
            $company = DB::select('select * from companies where user_id = ?', [Auth::id()]);
$events = Event::whereHas('users', function ($query) {
                $query->whereUserId(Auth::id())->where('company_id', '=', $company->id);
            })->orWhere('user_id', Auth::id())->where('company_id', '=', $company->id)->where('start_date', '>=', Carbon::now('America/Chicago'))->orderBy('start_date', 'asc')->get();
}

The table company_user holds the user_id and company_id user model

public function company()
{
  return $this->belongsTo('App\Company');
}

Thanks

Jul
16
3 months ago
Activity icon

Replied to Can't Create ForeignId On Users Table

@snapey, but I also want a "company" owner that is why I had an id on the company

Activity icon

Replied to Can't Create ForeignId On Users Table

Okay is it more efficient to put the company associate in a pivot table or on the user model?

Activity icon

Started a new Conversation Can't Create ForeignId On Users Table

Hey I have a users, and companies table.

On the users table I have:

$this->foreignId('company_id')->constrained();

companies table:

$this->foreignId('user_id')->constrained();

Each company can have 1 user as contact, but many users can belong to a company. When I run:

php artisan migrate:fresh

I get:

SQLSTATE[HY000]: General error: 1824 Failed to open the referenced table 'companies' (SQL: alter table `users` add constraint `users_company_id_foreign` foreign key (`company_id`) references `companies` (`id`))

Why does this not work? If I create a pivot table and remove the company_id off the user table it works fine.

Jul
13
3 months ago
Activity icon

Awarded Best Reply on Format Date With Carbon DiffForHumans

Setting the timezone in the now fixed it for me. Is this the best solution?

{{Carbon\Carbon::now('America/Chicago')->diffForHumans($events->first()->start_date)}}

Returns

1 hour after

Which is correct! Thanks for assisting me.

Activity icon

Replied to Format Date With Carbon DiffForHumans

Setting the timezone in the now fixed it for me. Is this the best solution?

{{Carbon\Carbon::now('America/Chicago')->diffForHumans($events->first()->start_date)}}

Returns

1 hour after

Which is correct! Thanks for assisting me.

Activity icon

Replied to Format Date With Carbon DiffForHumans

When I run

{{Carbon\Carbon::now()}}

Returns

"2020-07-13 13:50:05"

Which is off by 5 hours. I set env variable to:

APP_TIMEZONE=America/Chicago

And ran

php artisan config:clear
Activity icon

Replied to Format Date With Carbon DiffForHumans

@mvd it returns "5" I assume hours. Technically it should be 42 minutes ago and if it rounds up 1hr ago

Jul
12
3 months ago
Activity icon

Started a new Conversation Format Date With Carbon DiffForHumans

{{Carbon\Carbon::parse($events->first()->start_date)->diffForHumans()}}

Returns 4 hours from now.

The value is

2020-07-13 08:00:00

and current time on is 2020-07-12 22:42

I would like it to return "tomorrow" or even better would be ~9 hrs

Activity icon

Replied to Carbon Adds 7 Minutes To Date Time?

Lawd have mercy. It has been a long day. Thanks.

Activity icon

Started a new Conversation Carbon Adds 7 Minutes To Date Time?

My request returns

"07/13/2020 8:00 AM - 07/17/2020 5:00 PM"

Then explode

$datetimes = explode(' - ', $request->datetimes);

dd($datetimes[0])

"07/13/2020 8:00 AM"

Format string with carbon

\Carbon\Carbon::parse($datetimes[0])->format('d M, H:mA')

Returns

"13 Jul, 08:07AM"
Activity icon

Replied to How To Retrieve A Many To Many Relationship In A Frontend Table

each company has only 1 location right? If this is true switch from many to many to one to one inside your company model create a relationship for

public function location()
{
return $this->belongsTo('App\Location')
}

you could then call it using

{{$company->location->name}}

There are probably better methods to accomplish this, but I believe this will get you started.

Activity icon

Replied to How To Check Model Of Many To Many Polymorphic Association?

How can I create a method that checks a list of methods for not empty, and return the one that is not empty.

Activity icon

Replied to How To Check Model Of Many To Many Polymorphic Association?

Is there a better method to do this?

@forelse ($event->services as $service)
  {{$service->name}}
@empty
@endforelse

@forelse ($event->courses as $course)
  {{$course->name}}
@empty
@endforelse

In the future I would like to add more and check dynamically.

Activity icon

Replied to How To Check Model Of Many To Many Polymorphic Association?

when I run

{{class_basename($event)}}

It returns "Event", but I would like it to return the many to many polymorphic event relationship class for example "Course" or "Service".

Thanks

Jul
10
3 months ago
Activity icon

Started a new Conversation How To Check Model Of Many To Many Polymorphic Association?

How do I access many to many Polymorphic association type?

I have events that are schedulable. You can create events for services, and courses. When I Pull the relationship how do I determine what model (service or course) the event belongs to?

My dumb solution right now is to check if each relationship is empty $event->services->isNotEmpty(), $event->courses->isNotEmpty(). This doesn't doesn't seem like the right method, but I am a beginner to laravel, and I don't understand all the options yet. Could someone point me in the right direction?

Thanks

Jun
25
4 months ago
Activity icon

Replied to How Can I Change Md5 Passwords To Bcrypt In Laravel 5.4?

Hey All,

I just wanted to say thanks. I don't know if this is the best method for laravel 7, but it works great. I had the same issue. I needed to migrate users with md5 passwords to bcrypt. This was the simplest solution I found, although the code has slighly changed for the AuthenticatesUsers.php login function. Let me know if there is a better solution or method to accomplish this. I was looking into creating custom controller login etc, but that seemed like too much work. Then I was looking into mutators, but I need to learn more about how those work. I am a beginner.

The method I am currently using is a single column for password method. I have imported my old users into the database using the MD5 hashed passwords in the password column that is migrated with laravel. Then it converts that single value.

Same steps as others have mentioned open AuthenticatesUsers.php file and copy the login function into the LoginController.php

At the top of the file

add:

use Illuminate\Http\Request;
use App\User;

Then inside the login function include the method mentioned above:

// check the md5 password and change md5 to bcrypt if the user was found
        $user = User::where('email', $request->email)
                ->where('password',md5($request->password))
                ->first();
        if (!empty($user->id)) {
            $user->password = bcrypt($request->input('password'));
            $user->save();
        }

Final File:

<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\AuthenticatesUsers;

use Illuminate\Http\Request;

use App\User;

class LoginController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Login Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles authenticating users for the application and
    | redirecting them to your home screen. The controller uses a trait
    | to conveniently provide its functionality to your applications.
    |
    */

    use AuthenticatesUsers;

    /**
     * Where to redirect users after login.
     *
     * @var string
     */
    protected $redirectTo = RouteServiceProvider::HOME;

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest')->except('logout');
    }

    /**
     * Handle a login request to the application.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\Response|\Illuminate\Http\JsonResponse
     */
    public function login(Request $request)
    {
        // check the md5 password and change md5 to bcrypt if the user was found
        $user = User::where('email', $request->email)
                ->where('password',md5($request->password))
                ->first();
        if (!empty($user->id)) {
            $user->password = bcrypt($request->input('password'));
            $user->save();
        }

        $this->validateLogin($request);

        // If the class is using the ThrottlesLogins trait, we can automatically throttle
        // the login attempts for this application. We'll key this by the username and
        // the IP address of the client making these requests into this application.
        if (method_exists($this, 'hasTooManyLoginAttempts') &&
            $this->hasTooManyLoginAttempts($request)) {
            $this->fireLockoutEvent($request);

            return $this->sendLockoutResponse($request);
        }

        if ($this->attemptLogin($request)) {
            return $this->sendLoginResponse($request);
        }

        // If the login attempt was unsuccessful we will increment the number of attempts
        // to login and redirect the user back to the login form. Of course, when this
        // user surpasses their maximum number of attempts they will get locked out.
        $this->incrementLoginAttempts($request);

        return $this->sendFailedLoginResponse($request);
    }
}