Doubt in one function of "Yii by Example"

Im in page 98 of the ebook, and there’s an action to add in the Room controller:

public function actionLastReservationByRoomId($room_id)


        $room = Room::findOne($room_id);

        $lastReservation = $room->lastReservation;

        return $this->render('lastReservationByRoomId',['room' => $room, 'lastReservation' => $lastReservation]);


Im not sure what Room::findOne($room_id); do. If gets the room by ID, then why the next line does $room->lastReservation if the public function of the Room model to get the last reservation is getLastReservation() ?

The code works, but I want to understand what is doing :)

Active Record: Querying Data

Properties getters and setters

Active Record: Declaring Relations


The missing part was that $room->lastReservation is the same that $room->getLastReservation(). That solved my doubt :)