LiamA

Member Since 1 Year Ago

Experience Points
1,160
Total
Experience

3,840 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
2
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.

  • Community Pillar

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

Level 1
1,160 XP
Apr
22
3 weeks ago
Activity icon

Replied to Testing A Cookie Added Via Middleware

Well, I need to test both.

First I was testing that the cookie was getting set (globally) via the middleware.

Now I want to test some specific functionality that depends on the value of the cookie.

Why is there a conflict between the two?

Activity icon

Replied to Testing A Cookie Added Via Middleware

@martinbean In reference to my previous reply, while assertPlainCookie() does confirm the cookie is set, there is not way to access it and do the actual testing, for functionality that is dependent upon the cookie value!

Any idea how to resolve this??

Apr
21
3 weeks ago
Activity icon

Replied to Testing A Cookie Added Via Middleware

@martinbean Thank you! Your code works, all I had to do is use assertPlainCookie() instead of trying to fetch the cookie value using the Cookie facade with Cookie::get().

If I add the cookie to the request using the withCookie() method, Cookie::get() CAN access the cookie.

Does this make sense??

Activity icon

Started a new Conversation Testing A Cookie Added Via Middleware

Hi,

Is the only way to test cookies is using the withCookie() method?

I mean, I have a middleware defined where I check if a cookie is defined. If it's not, then I'm attaching a cookie to the request:

public function handle(Request $request, Closure $next)
{
    if(!$request->cookie('cart_id')){
    	$cart_id = "some value";
		return $next($request)->cookie(cookie()->forever('cart_id', $cart_id));
	}  
	return $next($request);
}     

It doesn't matter how many get requests I run in a test, then cookie remains undefined.

If I use browsers the cookie is there.

Is there no way to run this kind of test to confirm that the middleware is working properly?

Activity icon

Replied to Can't Set Cookies In Middleware

@chaudigv Thanks for replying.

Turns out my problems was elsewhere. Sanctum's middleware was added properly, and when testing via the browser it did work. I was trying to get that result in my tests. It turns out that for testing you need to manually set cookies (?) via the withCookie() method.

I'm going to ask a new question about this.

Apr
16
1 month ago
Activity icon

Started a new Conversation Can't Set Cookies In Middleware

I'm building a shopping cart SPA using Laravel and Vue.

Vue communicates with Laravel via the API, which is not a stateless as I'm using Sanctum for a cookie based session authentication services.

For guest users I want to store the cart info in a cookie. So I'm trying to set a cookie via a middleware I created with the following handle() method:

public function handle(Request $request, Closure $next)
{
    if(!$request->cookie('cart_id')){
    	$cart_id = "some value";
 return $next($request)->cookie(cookie()->forever('cart_id', $cart_id));
    }  
    return $next($request);
}    

I added this middleware to both 'api' and 'web' groups, but it doesn't seem to add the cookie no matter how many page requests I make.

Would appreciate some help with this Thanks

Mar
30
1 month ago
Activity icon

Replied to Lumen Vs Sanctum Vs Passport

thank you once more for a very insightful reply

Mar
26
1 month ago
Activity icon

Replied to Lumen Vs Sanctum Vs Passport

@fylzero Thank you for the thorough reply. I understand everything much better now.

Just one more question: Right now, the project I'm working on doesn't need to support 3rd part apps. In the future it might, but I can't tell for sure if and when that will be. Would using Sanctum now and then in the future (maybe) upgrade to Passport make sense?

Mar
24
1 month ago
Activity icon

Replied to Lumen Vs Sanctum Vs Passport

@fylzero Obviously you have a lot of experience building different types of sites and apps. Can you give us a few examples of scenarios where Sanctum won't do and Oauth provides extra functionality?

Mar
22
1 month ago
Activity icon

Replied to Can't Turns Off Cookie Encryption While Testing The API

But in order to test behaviour of the app that's consuming the API you do need states. Am I wrong?

I mean take for example the actingAs method:

$this->actingAs($user), 'api')

Isn't that what its for?

Activity icon

Replied to Can't Turns Off Cookie Encryption While Testing The API

I am testing a cookie I'm setting, not Laravel.

I managed to find a way to get the cookie value:

\Crypt::decrypt((Cookie::get('cookie-name')), false)

This returns a long string made of two sub strings separated by a pipe. The right sub string is the value i set in the cookie. I'm not sure what the left one is yet...

Activity icon

Replied to Can't Turns Off Cookie Encryption While Testing The API

But I'm relying on it's value, and want to make an assertion on it

Mar
21
1 month ago
Activity icon

Started a new Conversation Can't Turns Off Cookie Encryption While Testing The API

Hi,

I'm currently writing a test for an API endpoint involving the use of cookies.

My problem is that when I try to fetch the cookie value via Cookie::get(), I seem to be getting an encrypted value.

I tried adding the cookie name to the $except array in EncryptionCookies.php, but that doesn't seem to have changed anything.

I also tried clearing the cache of course.

Any ideas what's going on there?

Activity icon

Replied to Advice About Using 3rd Party Packages In Projects

@bugsysha @martinbean @jlrdw Thanks for you replies.

I decided not to use that package, and in general to minimize the number of packages I use

Mar
16
2 months ago
Activity icon

Started a new Conversation Advice About Using 3rd Party Packages In Projects

Hey everybody,

Just wanted to get some opinions about using 3rd party packages.

I'm about to start working on a new project, and I've been contemplating about whether I should minimize the number of 3rd party package I use.

For example, there is the laravel-enum package, which adds Enum support. I'm a big fan of Enums, and this package looks great. But, it is not an official Laravel package and I'm worried about potential security issues. Especially since I can do without it and use constants etc without making any big sacrifices code-wise.

So I just though I'd post this and maybe get some insights from the wisdom of this great community.

TIA