jump23

jump23

Member Since 2 Months Ago

Experience Points
310
Total
Experience

4,690 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
0
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 1
310 XP
Sep
19
1 month ago
Activity icon

Replied to PHP - Add Key In Foreach Loop

Sorry for answering twice, when I pass by reference, it works.

Activity icon

Replied to PHP - Add Key In Foreach Loop

Passing by reference was the solution. Thanks a lot.

Activity icon

Started a new Conversation PHP - Add Key In Foreach Loop

I am refreshing my PHP.

I was expecting this code to add the key-value pair "a" => "a" as a sibling to "d" => 1 of each item in the list.

<?php

$list = [
	"a" => [
		"x" => 
		[ 
			["d" => 1]
		]
	],
	"b" => [
		"x" => 
		[ 
			["d" => 1]
		]
	]
];

foreach($list as $item) {
	$item["x"][0]["a"] = "a";
}

print_r($list);

This doesn't work.

When I access the first element directly, it works:

$list["a"]["x"][0]["a"] = "a";

Why is that?

Thanks for your help.

Sep
18
1 month ago
Activity icon

Started a new Conversation Organize Ajax States In App Using Vuex

Hello,

When you have all your API calls (axios) in a Vuex store, how do you organize the loading states? In my app, there are the usual states not_loaded, loading, loaded, and loading_failed. Currently, I use one state variable per API call.

I use JavaScript. How do you represent the ajax state vaues, do you use some kind of quasi enum?

Thanks.

Sep
01
1 month ago
Activity icon

Replied to Sanctum - Make API Endpoints Accessible For External Http Clients

Thanks for your reply.

The cited section explains how you issue a token.

However, I would like to configure the Sanctum so that requests don't have to come from the same top-level domain.

Maybe I'm overlooking something? :)

Activity icon

Started a new Conversation Catch Custom Exception Thrown By Middleware

I have a middleware that throws a custom exception:

<?php

namespace App\Http\Middleware;


use Closure;
use App\Exceptions\InvalidContentTypeException;
use App\Exceptions\CustomException;

class SomeMiddleware
{
   
    public function handle($request, Closure $next)
    {
		if(some logic) {
			throw new CustomException();
		}
		
        return $next($request);
    }
}

In my Handler.php, printing the exception name works:

    public function render($request, Throwable $exception)
    {
		$exception_name = get_class($exception);
		return response()->json(["exception" => $exception_name], 404);
    }

This will output:

{
    "exception": "App\Exceptions\CustomException"
}

However, catching it doesn't.

Am I just catching it the wrong way?

At the top of Handler.php I have:

use CustomException;

But this will evaluate to false in handle():

$is_custom = $exception instanceof CustomException;

Using the fully qualified name ($exception instanceof App\Exceptions\CustomException) doesn't help either.

Thanks for your help.

Aug
29
2 months ago
Activity icon

Replied to Add Validation Of Content Type To Store() Of Resource Controllers

That's true. So would you simply leave the option to submit form data open, even if you are expecting (nested) JSON as the input?

Activity icon

Started a new Conversation Sanctum - Make API Endpoints Accessible For External Http Clients

I have started reading about Sanctum. The docs say:

"In order to authenticate, your SPA and API must share the same top-level domain. However, they may be placed on different subdomains."

URL: https://laravel.com/docs/7.x/sanctum

In my application, I want to make a few API endpoints accessible via curl (or any other external http client). How can I configure this?

Activity icon

Replied to Add Validation Of Content Type To Store() Of Resource Controllers

Thanks.

Why does the resource controller accept input data supplied as form data and json payloads in the first place? I have just started learning Laravel and haven't seen this before. I would assume that most people simply let the consumer decide how to pass the data? Sure, as far as I can see, nested data can only be applied as json.

Activity icon

Replied to Add Validation Of Content Type To Store() Of Resource Controllers

Thanks for your reply.

How would I check in the middlewear if the store() method is being requested?

Activity icon

Started a new Conversation Add Validation Of Content Type To Store() Of Resource Controllers

In all of my resource controllers, I want the store() method to accept only requests with content type "json/application". Checking the content type as such isn't the problem.

My question is what would be a good pattern to add this validation to all resource controllers.

Should I create an ApiController class that extends Controller?

Does Laravel have a built-in feature for this?