JohnnyW2001

JohnnyW2001

Member Since 2 Years Ago

Experience Points
7,770
Total
Experience

2,230 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
69
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start-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-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-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist 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 2
7,770 XP
12 Sep
1 week ago

JohnnyW2001 left a reply on Customising Forgotten Password

Perfection! Thanks very much

JohnnyW2001 started a new conversation Customising Forgotten Password

I have a system where the user can have an "email" entry into our database before they've created an account. For the rest of our app, we check the status of the password column. If it's NULL then we know they haven't registered yet.

Unfortunately, Laravel only checks for the instance of an email address before sending out a Forgotten Password email. I can write my own little check for a null password column in the sendResetLinkEmail() method, but it feels it would be neater to put the check wherever Laravel checks for the presence of an email address... but where does this happen? (I'm talking about the method that results in the message "We can't find a user with that e-mail address.")

Thanks.

27 Jun
2 months ago

JohnnyW2001 left a reply on Custom Pivot Table Not Being Respected?

Thank you! I'm using 5.8 and your tweak made the difference. Not sure why I didn't see it in the docs.

Edit: Because it's not in the docs :-/

https://laravel.com/docs/5.8/eloquent-relationships#defining-custom-intermediate-table-models

JohnnyW2001 started a new conversation Custom Pivot Table Not Being Respected?

I'm not sure what I've done wrong, but whenever I try to get a model's attributes from a pivot table, Laravel is looking in the wrong place.

Person model:

  protected $connection = 'second';
  protected $table = 'people';

  public function permissionTypes() {
      return $this->belongsToMany('App\PermissionType')->using('App\PersonPermission');
  }

PermissionType model:

protected $connection = 'second';

public function people() {
    return $this->belongsToMany('App\Person')->using('App\PersonPermission');
}

PeoplePermission model:

class PersonPermission extends Pivot
{
    protected $connection = "second";
    protected $table = "people_permissions";
}

And yet in Tinker:

$person->permissionTypes

Error: Table 'second.permission_type_person' doesn't exist

Why is it looking for permission_type_person? :(

21 Mar
6 months ago

JohnnyW2001 left a reply on Session Not Persisting

It was a mistake in my code, not Laravel. Ignore.

JohnnyW2001 started a new conversation Session Not Persisting

UPDATE: It wasn't Laravel, it was my code. I WAS overwriting the value. Ignore the below.

*I understand that a request must fully complete for session data to be persisted, but I can't understand why one area of my app isn't doing that (while in others it's working fine).

There's POST request which is routed to a Controller, which (in turn) instantiates a Model and calls a method which runs the following:

session(['currentAttendance' => $id]);

After that completes successfully (which I can see in my debugging console), the controller runs:

return redirect()->route('profile');

But by the time the profile page appears, session('currentAttendance') is returning the previous value again.

Nothing is additionally changing the value, it just appears to not be persisting. There's no premature termination that I can see. No dd() etc.

Why isn't it working?*

18 Feb
7 months ago

JohnnyW2001 left a reply on Laravel PHPStorm PHPUnit

Some missing information: You also need to go to Language & Frameworks > PHP and set the CLI interpreter version.

Finally you can run tests with CTRL+SHIFT+R (placing your mouse in a test method that you want to test).

05 Jul
1 year ago

JohnnyW2001 left a reply on Assets Not Being Served Over HTTPS

The solution was a trusted proxies issue. You can read more here:

https://laravel.com/docs/5.6/requests#configuring-trusted-proxies

All I had to do (as an AWS Elastic Beanstalk user) was edit app/Http/Middleware/TrustProxies.php:

class TrustProxies extends Middleware
{
    /**
     * The trusted proxies for this application.
     *
     * @var array
     */
    protected $proxies = '*';

    /**
     * The headers that should be used to detect proxies.
     *
     * @var int
     */
    protected $headers = Request::HEADER_X_FORWARDED_AWS_ELB;
}

Now everything is fine.

JohnnyW2001 left a reply on Using Amazon SQS With Laravel

The answer was that it needed higher credentials

04 Jul
1 year ago

JohnnyW2001 left a reply on Assets Not Being Served Over HTTPS

I have not altered the .htaccess file at all

JohnnyW2001 started a new conversation Assets Not Being Served Over HTTPS

I have no idea why this has suddenly become an issue, as I don't recall coming across this problem before when using Laravel. But with my new project, when I deploy my app to my https:// domain, every {{ asset() }} and every {{ route() }} is being served over http.

My APP_URL is correctly set to https, and as I say, I don't recall ever having this issue with previous Laravel applications.

What have I done wrong?

04 Apr
1 year ago

JohnnyW2001 started a new conversation Using Amazon SQS With Laravel

I've configured Laravel to queue email messages which are being sent by my site using Amazon SQS. The service itself seems to work fine. I can see all the messages appears in the SQS queue in my AWS account, but the problem is that the queue just seems to be getting bigger and bigger.

I can't find any decent tutorials or guides that explain how to read the SQS screen written in plain English, so everything MAY be fine. That said, I'd like to make sure.

Consider what SQS is currently saying:

Messages available: 310
Messages in Flight: 4
Messages delayed: 0

When I tested it when it first went live, messages were being sent immediately. The queue was empty and they arrived in my inbox without issue.

Today the queue ("Message available") appears to be 310 and it's only going up! (Edit: Ok, it's hovering around 300 now, but also going up to 302 at times.) Now it's taking several hours for messages to appear in my inbox... In fact, I'm still waiting for some to appear from several hours ago.

Is this normal? I've checked my server. I've now added five processes running php artisan queue:work, each consuming ~5% of the CPU.

If I manually run the same command (instead of as nohup) I see constantly updating list:

[2018-04-04 20:09:59] Processing: App\Notifications\CompetitionAll
[2018-04-04 20:09:59] Processing: App\Notifications\CompetitionVIP
[2018-04-04 20:10:00] Processing: App\Notifications\CompetitionVIP
[2018-04-04 20:10:00] Processing: App\Notifications\CompetitionVIP
[2018-04-04 20:10:00] Processing: App\Notifications\CompetitionAll
[2018-04-04 20:10:00] Processing: App\Notifications\CompetitionAll
[2018-04-04 20:10:00] Processing: App\Notifications\CompetitionAll
[2018-04-04 20:10:02] Processing: App\Notifications\CompetitionAll
[2018-04-04 20:10:02] Processing: App\Notifications\CompetitionAll
[2018-04-04 20:10:02] Processing: App\Notifications\CompetitionAll
[2018-04-04 20:10:02] Processing: App\Notifications\CompetitionAll
[2018-04-04 20:10:02] Processing: App\Notifications\CompetitionAll
[2018-04-04 20:10:02] Processing: App\Notifications\CompetitionAll
[2018-04-04 20:10:03] Processing: App\Notifications\CompetitionAll
[2018-04-04 20:10:03] Processing: App\Notifications\CompetitionAll
[2018-04-04 20:10:03] Processing: App\Notifications\CompetitionAll
[2018-04-04 20:10:03] Processing: App\Notifications\CompetitionAll
[2018-04-04 20:10:03] Processing: App\Notifications\CompetitionAll

Only every so often does one change to Processed, most of the time it's an endless list of yellow Processing, changing every second.

Any help understand what's going on would be greatly appreciated!

09 Jan
1 year ago

JohnnyW2001 started a new conversation Connection Refused In AWS Deploy

I've been developing Laravel app and deploying regularly to an Elastic Beanstalk instance without issue, but suddenly, and without warning, deployments have begun to fail.

Obviously I immediately wondered what I might have changed in the code to cause this, but I haven't made any changes to the core configuration. I rolled back to an earlier commit just to make sure it wasn't my code, and I got the same error.

It's failing after I run eb deploy and running the .ebextensions configs.

Here's the error message from the logs:

[2018-01-08T10:50:34.672Z] INFO  [9457]  : Running 4 of 5 actions: EbExtensionPostBuild... 
[2018-01-08T10:50:35.523Z] ERROR [9457]  : Command execution failed: Activity failed. (ElasticBeanstalk::ActivityFatalError) caused by:   

In Connection.php line 664:
     SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema = custom and table_name
= migrations)
  
     In Connector.php line 67:
     SQLSTATE[HY000] [2002] Connection refused
  
      (ElasticBeanstalk::ExternalInvocationError)

The DB connection credentials are absolutely correct (and haven't changed either).

The command that it's attempting when it fails is simply:

php artisan migrate --force

I've tried connecting over SSH to the server, and I can manually run the same command without issue.

I just can't understand why the deployment is suddenly having its connection refused. Could it be something to do with the AWS security configuration? Could it expire or something? :-/

08 Dec
1 year ago

JohnnyW2001 left a reply on Bulk Insert Without Specifying Column Names

Nevermind, that worked and it was very quick! Thanks!

JohnnyW2001 left a reply on Bulk Insert Without Specifying Column Names

+1 That definitely possible, and as this is only happening once, feasible, but I wonder if there's another way?

JohnnyW2001 started a new conversation Bulk Insert Without Specifying Column Names

A simple request, but I have to pre-populate a database with hundreds of entries. I've created a custom command to handle everything and it's working great, except for the largest bulk insert (hundreds of entries in its own right).

I'd much prefer it if I could simply use the following:

    DB::table('pupils')->insert([
        ['Katy', 'Walker', 'female', '1'],
        ['Nancy','Jones','female','32'],
        ['Natalie','Smith','female','974'],
        ['Pamela','James','female','9'],
        ...

Which is possible in SQL, but instead it seems I have to:

    DB::table('pupils')->insert([
        [
            'first_name' => 'Katy',
            'last_name' => 'Walker',
            'gender' => 'female',
            'student_loan_id' => '1'
        ],
        [
            'first_name' => 'Nancy',
            'last_name' => 'Jones',
            'gender' => 'female',
            'student_loan_id' => '32'
        ],
        ...

I know it's dirty, but it's only happening once and it would save me a lot of work.

Is it possible at all to bulk insert without having to specify the column names?

05 Dec
1 year ago

JohnnyW2001 left a reply on Correct Way To Pre-populate Database

Actually it turned out to be very easy. Thanks for the tip, @martinbean !

JohnnyW2001 left a reply on Correct Way To Pre-populate Database

@martinbean Thanks, that sounds like the best solution, although perhaps a non-trivial thing to implement?

https://laravel.com/docs/5.5/artisan#writing-commands

JohnnyW2001 left a reply on Correct Way To Pre-populate Database

@tykus That makes sense, thanks. I guess that's why I was wondering if there's a better way, but instead I'll just have to be very careful and plan properly.

JohnnyW2001 left a reply on Correct Way To Pre-populate Database

@martinbean Are you talking about php artisan db:seed?

JohnnyW2001 started a new conversation Correct Way To Pre-populate Database

Is there a good way to populate a database during deployment? Our site needs to have a lot of hardcoded values added to certain tables before the site can go live. The documentation says Seeders are used for TEST data. Is there a better way for data that isn't just for testing?

04 Dec
1 year ago

JohnnyW2001 left a reply on Upgrading Laravel (patch Release Only)

Thanks! It seems I might be experiencing this bug: https://github.com/laravel/framework/issues/21146 Unfortunately if I am, it's not going to be publicly fixed for a while (current Laravel version is apparently 5.5.22).

Maybe my issue is something else, though.

JohnnyW2001 started a new conversation Upgrading Laravel (patch Release Only)

Apparently patch releases should NEVER be breaking (patch releases are 5.5.x), so if I think I'm experiencing a bug, how can I get the latest patch release for my project?

I'm current running 5.5.18, but I would like to try running the latest 5.5.x to see if it fixes an issue I'm having.

How can I do this?

23 Nov
1 year ago

JohnnyW2001 left a reply on Why The Attach Method Returns Null When Successfully Inserted?

I'm guessing this hasn't changed? :-/

21 Nov
1 year ago

JohnnyW2001 left a reply on There Are No Commands Defined In The "make:migration" Namespace.

In case this was unclear, the make:migration:pivot command is only available if you have the Laravel 5 Extended Generators package installed. Not having it installed is why you got that error message.

If you install it, it will add the following generators:

make:migration:schema

make:migration:pivot

make:seed

14 Jul
2 years ago

JohnnyW2001 left a reply on Column Sorting With Pagination On Laravel 5.1

What would help is if @jlrdw deleted his obnoxious and unhelpful answers. (BTW - There's no apology in this thread, jlrdw.)

To make matters worse jlrdw's answers aren't merely obnoxious and unhelpful, they're absolutely wrong, too.

11 Jul
2 years ago

JohnnyW2001 left a reply on [L5] Validating Multiple File Input

@canflax Amazingly that worked! Thanks!

06 Jul
2 years ago

JohnnyW2001 left a reply on Ajax FormData And PUT Fails

Ugh. I still cannot see my data, though :-/

05 Jul
2 years ago

JohnnyW2001 left a reply on Symlink Confusion: Why Does Storage:link Do This?

Thank you, you're right! But it still means I need to references images with {{ asset('storage/'.$file) }}.

Is this right?

30 Jun
2 years ago

JohnnyW2001 started a new conversation Symlink Confusion: Why Does Storage:link Do This?

When running php artisan storage:link (as per the documentation), a symlink between public/storage/ to storage/app/public is created. I realise this is by design, but it leads to some very confusing behaviour not covered by the documentation.

For example: If you saveAs a file to an avatars directory, it's stored in: storage/app/avatars and the path returned (for database storage) is: avatars/filename.jpg. This is outside the symlink. Instead we need to tell it saveAs to storage/app/public/avatars (which results in a path returned for database storage being: public/avatars/filename.jpg).

According to the documentation, all we need to do to refer to this file is asset('avatars/filename.jpg') in our code, but that doesn't work. (And neither does the string we stored: asset('public/avatars/filename.jpg').) Instead it needs to be asset('storage/avatars/filename.jpg').

Which means we need to do a str_replace('public', 'storage', asset($filename)) to make an application work as per the documentation's instructions :-/

I assume I'm doing something wrong, but this so very confusing! Is there a better way to deal with this behaviour?

15 Jun
2 years ago

JohnnyW2001 left a reply on Laravel Mix And Autoprefixer

Ah, thank you!!

08 Jun
2 years ago

JohnnyW2001 left a reply on Laravel Mix And Autoprefixer

Hmm. I'm looking through node_modules/laravel-mix/setup/webpack.config.js and there's no mention of Autoprefixer? Am I missing something? :-/