Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Build a REST API with Laravel API Basics & CRUD operations Resource Controllers (CRUD)

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,252 Points

Regarding the Book update() method

public function update(Request $request, Photo $photo)
    {
        //
        $data = $request->validate([
            "url" => "required",
            "caption" => "required",
            "owner_id" => "required"
        ]);

        //owner->update($data);  - not included in video
        return response( $photo->update($data), 200 );

    }

I'm confused as to why Jonathan (the instructor doesn't include the line that I've commented out at 13 minutes into the video?

Thanks! :-)

I'm also curious why line 34 at 5:55 (in AuthorController.php)

return response(Author::create($data), 201); // 201 Created

differs, syntactically, from line 33 at 13:03 (in BookController.php)

$book = Book::create($data);

(both are the last line of the store function, respectively) ???