1 | <?php |
||
11 | class Includable |
||
12 | { |
||
13 | private $default_columns = []; |
||
14 | private $allow_columns = []; |
||
15 | private $columns = []; |
||
16 | private $relation; |
||
17 | private $nested = false; |
||
18 | private $name; |
||
19 | private $foreign_key; |
||
20 | private $limit; |
||
21 | private $parent_name; |
||
22 | private $children = []; |
||
23 | private $with_trashed = false; |
||
24 | |||
25 | public function __construct($name) |
||
29 | |||
30 | /** |
||
31 | * 获取这个引入项的字段. |
||
32 | * |
||
33 | * @return array |
||
34 | * |
||
35 | * @throws \Exception |
||
36 | */ |
||
37 | public function getColumns() |
||
45 | |||
46 | /** |
||
47 | * 设置这个引入项的字段. |
||
48 | * |
||
49 | * @param array $columns |
||
50 | * |
||
51 | * @return $this |
||
52 | */ |
||
53 | public function setColumns($columns) |
||
59 | |||
60 | /** |
||
61 | * 获取这个引入项默认引入的字段. |
||
62 | * |
||
63 | * @return array |
||
64 | * |
||
65 | * @throws \Exception |
||
66 | */ |
||
67 | public function getDefaultColumns() |
||
75 | |||
76 | /** |
||
77 | * 设置这个引入项默认引入的字段. |
||
78 | * |
||
79 | * @param array|string $default_columns |
||
80 | * |
||
81 | * @return $this |
||
82 | */ |
||
83 | public function setDefaultColumns($default_columns) |
||
89 | |||
90 | /** |
||
91 | * 获取这个引入项的名称. |
||
92 | * |
||
93 | * @return string |
||
94 | * |
||
95 | * @throws \Exception |
||
96 | */ |
||
97 | public function getName() |
||
105 | |||
106 | /** |
||
107 | * 设置这个引入项的字段. |
||
108 | * |
||
109 | * @param string $name |
||
110 | * |
||
111 | * @return $this |
||
112 | */ |
||
113 | public function setName($name) |
||
119 | |||
120 | /** |
||
121 | * 获取这个引入项关联的外键,仅 belongTo 关系需要设置. |
||
122 | * |
||
123 | * @return string |
||
124 | * |
||
125 | * @throws \Exception |
||
126 | */ |
||
127 | public function getForeignKey() |
||
135 | |||
136 | /** |
||
137 | * 获取这个引入项关联的外键. |
||
138 | * |
||
139 | * @param string $foreign_key |
||
140 | * |
||
141 | * @return $this |
||
142 | */ |
||
143 | public function setForeignKey($foreign_key) |
||
149 | |||
150 | /** |
||
151 | * 获取引入条数限制. |
||
152 | * |
||
153 | * @return int |
||
154 | * |
||
155 | * @throws \Exception |
||
156 | */ |
||
157 | public function getLimit() |
||
165 | |||
166 | /** |
||
167 | * 设置引入条数限制, 仅对多关系时设置(hasMany, belongsToMany, etc..). |
||
168 | * |
||
169 | * @param int $limit |
||
170 | * |
||
171 | * @return $this |
||
172 | */ |
||
173 | public function setLimit($limit) |
||
179 | |||
180 | /** |
||
181 | * 获取允许被客户端引入的字段. |
||
182 | * |
||
183 | * @return array |
||
184 | */ |
||
185 | public function getAllowColumns() |
||
189 | |||
190 | /** |
||
191 | * 设置允许被客户端引入的字段. |
||
192 | * |
||
193 | * @param mixed $allow_columns |
||
194 | * |
||
195 | * @return $this |
||
196 | */ |
||
197 | public function setAllowColumns(array $allow_columns) |
||
203 | |||
204 | /** |
||
205 | * 计算出需要哪些字段. |
||
206 | */ |
||
207 | public function figureOutWhichColumns() |
||
213 | |||
214 | /** |
||
215 | * 获取对应于 model 的关联方法. |
||
216 | * |
||
217 | * @return string |
||
218 | */ |
||
219 | public function getRelation() |
||
223 | |||
224 | /** |
||
225 | * 设置对应于 model 的关联方法. |
||
226 | * |
||
227 | * @param mixed $relation |
||
228 | * |
||
229 | * @return $this |
||
230 | */ |
||
231 | public function setRelation($relation) |
||
237 | |||
238 | /** |
||
239 | * 设置这个引入项目是否是嵌套的. |
||
240 | * |
||
241 | * @param $parent string 父引入项名 |
||
242 | * |
||
243 | * @return $this |
||
244 | */ |
||
245 | public function nested($parent) |
||
252 | |||
253 | /** |
||
254 | * 同时查询软删除的数据. |
||
255 | * |
||
256 | * @return $this |
||
257 | */ |
||
258 | public function withTrashed() |
||
264 | |||
265 | /** |
||
266 | * 是否要查询软删除的数据. |
||
267 | * |
||
268 | * @return bool |
||
269 | */ |
||
270 | public function isWithTrashed() |
||
274 | |||
275 | /** |
||
276 | * 获取这个引入项目是否是嵌套的. |
||
277 | * |
||
278 | * @return bool |
||
279 | */ |
||
280 | public function isNested() |
||
284 | |||
285 | /** |
||
286 | * 获取一个新的自身的实例. |
||
287 | * |
||
288 | * @param $name |
||
289 | * |
||
290 | * @return Includable |
||
291 | */ |
||
292 | public static function make($name) |
||
296 | |||
297 | /** |
||
298 | * 获取父引入项名. |
||
299 | * |
||
300 | * @return mixed |
||
301 | */ |
||
302 | public function getParentName() |
||
306 | |||
307 | /** |
||
308 | * 获取所有子引入项. |
||
309 | * |
||
310 | * @return Includable[] |
||
311 | */ |
||
312 | public function getChildren() |
||
316 | |||
317 | /** |
||
318 | * 添加一个子引入项目. |
||
319 | * |
||
320 | * @param mixed $children |
||
321 | */ |
||
322 | public function addChildren(Includable $children) |
||
326 | } |
||
327 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.