12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <?php
- namespace common\util;
- use common\models\AccidentCases;
- use JsonSerializable;
- /**
- * Class AccidentCasesFocusObj
- * @package common\util
- * @property int $id
- * @property string $title
- * @property string images
- * @property int start_time
- */
- class AccidentCasesFocusObj implements JsonSerializable
- {
- private int $id;
- private ?string $title;
- private ?string $images;
- private ?int $start_time;
- /**
- * @return int
- */
- public function getId(): int
- {
- return $this->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,
- ];
- }
- }
|