claytoningmire

Member Since 11 Months Ago

Experience Points
11,040
Total
Experience

3,960 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
107
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 3
11,040 XP
Jan
26
1 month ago
Activity icon

Awarded Best Reply on Factory Definition Sequence

After some sleep I realized I was attempting to do this incorrectly. Instead of creating the Sequence in the Factory, you should be creating the Sequence in the Seeder like so:

public function run()
{
    BlogPost::factory()
        ->count(6)
        ->sequence(
            ['published' => now()],
            ['published' => null]
        )
        ->create();
}
Activity icon

Replied to Factory Definition Sequence

With this acknowledged, I do think having the ability to create the Sequence in the Factory would be ideal.

Activity icon

Replied to Factory Definition Sequence

After some sleep I realized I was attempting to do this incorrectly. Instead of creating the Sequence in the Factory, you should be creating the Sequence in the Seeder like so:

public function run()
{
    BlogPost::factory()
        ->count(6)
        ->sequence(
            ['published' => now()],
            ['published' => null]
        )
        ->create();
}
Jan
25
1 month ago
Activity icon

Started a new Conversation Factory Definition Sequence

Is it possible to use a Sequence in a Factory definition()?

I have tried all of the following to get a result but to no avail.

'published' => $this->sequence([now(), null])

'published' => $this->sequence(now(), null)

'published' => $this->state(new Sequence([now(), null]))

'published' => new Sequence([now(), null])
Jan
21
1 month ago
Activity icon

Replied to Laravel 8 API - Show() Method Help

I now know it was because my route was looking for blog not blog_post so I modified my controller. I see I could also alter my rout to look point to /blog_post

Activity icon

Started a new Conversation Laravel 8 API - Show() Method Help

I have some controllers and resources for different models like users and blog posts. Every endpoint for my user model is working properly. I modeled my blog post model, controller, and resources similarly but the blog post model does not work when requesting specific posts. Blog post methods like index() and store() are working properly however.

api.php

Route::prefix('v1')->group(function (){
    Route::apiResource('/blog', 'App\Http\Controllers\API\v1\BlogPostController');
}

BlogPostController.php

/**
 * @param BlogPost $blog_post
 * @return BlogPostResource
 */
public function show(BlogPost $blog_post) : BlogPostResource
{
    return new BlogPostResource($blog_post);
}

/**
 * @return BlogPostResourceCollection
 */
public function index() : BlogPostResourceCollection
{
    return new BlogPostResourceCollection(BlogPost::paginate());
}

The BlogPostResource() is a default resource created with artisan. The BlogPostResourceCollection() is a resource created with artisan and the --collection flag applied.

I am targeting .../v1/blog/2 which is an existing blog post id.

Using the index() method endpoint proves our blog post with id of 2 exists

    {
        "id": 2,
        "created_at": "2021-01-21T01:29:36.000000Z",
        "updated_at": "2021-01-21T01:29:36.000000Z",
        "user_id": 52,
        "title": "quae porro laborum incidunt vel",
        "body": "Molestiae eius debitis..."
    },

When I dd() on $blog_post in show() I get this as one of the returned fields +exists: false.

I must be missing something.

It may be worth noting that my user model has this method:

public function blogPosts() {
    return $this->hasMany(BlogPost::class);
}

...and my blog post model has this method:

public function author() {
    $this->belongsTo(User::class);
}

The user_id field in a blog post is a foreign key referencing user.id.

The only methods that don't work are those that accept a BlogPost as an argument.

I changed the api.php file to contain only this route:

Route::get('/v1/blog/{blog_post}', function(BlogPost $blog_post){return $blog_post;});

...which was successful but I want this to work in the other route.

Response from php artisan route:list

| api.rest-api.test | GET|HEAD  | v1/blog        | blog.index   | App\Http\Controllers\API\v1\[email protected]   | api        |
| api.rest-api.test | POST      | v1/blog        | blog.store   | App\Http\Controllers\API\v1\[email protected]   | api        |
| api.rest-api.test | GET|HEAD  | v1/blog/{blog} | blog.show    | App\Http\Controllers\API\v1\[email protected]    | api        |
| api.rest-api.test | PUT|PATCH | v1/blog/{blog} | blog.update  | App\Http\Controllers\API\v1\[email protected]  | api        |
| api.rest-api.test | DELETE    | v1/blog/{blog} | blog.destroy | App\Http\Controllers\API\v1\[email protected] | api        |
Jan
01
2 months ago
Activity icon

Replied to Reactjs Tutorials

An updated Laravel+React video would be fantastic.