Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

Jonathan Grieve
Jonathan Grieve
Treehouse Moderator 90,704 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) ???