AlecWeekes

AlecWeekes

Member Since 10 Months Ago

Experience Points
2,700
Total
Experience

2,300 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
10
Lessons
Completed
Best Reply Awards
2
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 1
2,700 XP
Apr
29
2 months ago
Activity icon

Replied to Partial JWT & Laravel Session Login

The long-term plan is to rebuild our current code base as an all powerful API that can serve multiple frontend applications, but I'll certainly take a look at Sanctum, but does this allow for the authorisation between Web & Api routes?

I see a lot of Api discussion on Sanctum, and not a lot of Web.

It's pretty much because I've used JWT & Nuxt for a while now and it's what I am most comfortable with.

Activity icon

Started a new Conversation Partial JWT & Laravel Session Login

I'm wondering if anyone can give any tips or advice on the best approach for tackling a rather complicated, and frustrating issue I am having.

I've started working at a new company and we're in the midst of migrating all our frontend over to Nuxt & Vue, but given the scale of the project we need to do this incrementally. I've started the work, and all seems to be going well except for authenticating a user between Nuxt & Laravel.

I'm using JWT / Bearer Tokens for the Nuxt authentication, and they're using Laravel Sessions (Auth::attempt()) for their old stuff.

My Nuxt project is working fine, I'm able to authenticate using login credentials on the old code base, and I am able to make requests to their API, but the problem I face is a lot of their Controllers aren't accessible as an API, and so rather than re-writing it all right now (albeit that is the plan), I need a rather sleek way of authenticating a user for both the api & web routes at the same time.

I've considered a few options such as storing the authenticated user in Redis, passing session data in the API responses to the login, but I really want to know if anyone here has experience with something similar and has a sleek and nice way on conceptually doing this?

I unfortunately can't provide much code, but if there is something specific you wish to see I may be able to refactor for demonstration purposes.

I appreciate the help any of you could provide. I'm pulling my hair out here.

Apr
16
2 months ago
Activity icon

Replied to How To Get Middleware To Fire?

@talinon - Thanks for the update. I should've specified these are Unit tests, not Feature tests.

Since finding some more information about these out, I'm refactoring my tests to follow the lines you've outlined. I think I was just stuck in a rut of "One worked this way, so surely this is the best way to go about it!"

Thanks again!

Activity icon

Awarded Best Reply on How To Get Middleware To Fire?

I'm convinced that by simply posting here on Laracasts, I find the solution a few moments later.

The solution for myself wasn't the make a direct call to the method, but rather to make a call to the route itself.

Making a call like $response = $this->get('/route'); meant that it had to pass through my route layer, and everything as needed was called.

Hopefully this helps someone else though in the same boat!

Activity icon

Replied to How To Get Middleware To Fire?

I'm convinced that by simply posting here on Laracasts, I find the solution a few moments later.

The solution for myself wasn't the make a direct call to the method, but rather to make a call to the route itself.

Making a call like $response = $this->get('/route'); meant that it had to pass through my route layer, and everything as needed was called.

Hopefully this helps someone else though in the same boat!

Activity icon

Started a new Conversation How To Get Middleware To Fire?

Morning / Afternoon / Evening,

I'm wondering if someone else has encountered a way to ensure that Middleware is running on your tests.

We're currently doing a lot of Auth::check() & Auth::user()-> checks in our methods, but we're moving to using Middleware on our constructors like so;

  public function __construct() {
      parent::__construct();

      $this->middleware(['auth']);
  }

This is working just fine in real use cases, but inside the tests it's not working as intended.

I have the following method;

  public function method() {
    if(Auth::user()->can('doSomething')) {
    }
}

When inside my test I do the following;

        $request = Request::create('/route', 'GET', []);

        $controller = new MyController();
        $response = $controller->method($request);

But the test is complaining that the Auth::user() is null. Now, this is actually my intention. I'm wanting to write a test to ensure that my method is not accessible by those not authenticated in my application.

I was under the impression that even with calling $controller->method(); the __construct() should still be called, and so the Middleware should then handle the situation, and return the correct response.

Am I missing something obvious? I feel like I'm going around in circles going crazy.

Any help would be appreciated. I have had a search online, and even here on Laracasts, but I am unable to find something related to wanting to explicitly make sure that middleware is running on my tests.

Apr
15
2 months ago
Activity icon

Replied to Laravel 7, Test Command Not Working

Nevermind - It's now running...

Not sure what was going on, I went for a smoke break and ran it again and now it's working. Weird.

Thanks @bugsysha for the recommendation on Laravel Shift. I'll certainly look into that for future upgrades!

Activity icon

Started a new Conversation Laravel 7, Test Command Not Working

Afternoon everyone,

Hope you're all doing well. I was just wondering if someone had any insight into exactly what is going wrong with my artisan command. Perhaps it's something simple I've missed and I've been at the desk too long.

I've just upgraded from Laravel 6 -> Laravel 7, and I'm running through making sure everything works. Attempting to run my tests works fine as usual when firing vendor/bin/phpunit but I noticed that apprently there is now php artisan test that can be run.

I've given that a shot, and it's not working. It's attempting to interpret it as make:test it seems, and isn't at all a fan.

I'm wondering if I've been an idiot and forgotten something. Hopefully someone here can lend a hand?

Notes:

  • Laravel v7
  • I've composer du and reset the artisan cache (php artisan optimize:clear)
  • When doing php artisan list it displays I am on Laravel 7, but doesn't show the test command in the list.
  • When running composer show phpunit/phpunit it confirms I am on v8.5

If you need anymore information, let me know.

Cheers!