id; } /** * @param int $id */ public function setId(int $id): void { $this->id = $id; } /** * @return string */ public function getTitle(): string { return $this->title; } /** * @param string $title */ public function setTitle(string $title): void { $this->title = $title; } public function __construct(AccidentCases $AccidentCases) { $this->id = $AccidentCases->id; $this->title = $AccidentCases->title; $this->images = $AccidentCases->images; $this->start_time = $AccidentCases->start_time; } /** * json_encode无法转化私有属性,需要使用jsonSerialize自定义转换私有的属性 * @return array */ public function jsonSerialize(): array { return [ "id" => $this->id, "title" => $this->title, "images" => $this->images, "start_time" => $this->start_time, ]; } }