File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,14 @@ abstract class Model extends \Jenssegers\Eloquent\Model {
28
28
*/
29
29
protected $ primaryKey = '_id ' ;
30
30
31
+ /**
32
+ * Allow json attributes to be exposable. This is mainly for
33
+ * relations that can be kept alive in a toJson()
34
+ *
35
+ * @var array
36
+ */
37
+ protected $ expose = [];
38
+
31
39
/**
32
40
* The connection resolver instance.
33
41
*
@@ -284,7 +292,7 @@ public function attributesToArray()
284
292
// internal array of embedded documents. In that case, we need
285
293
// to hide these from the output so that the relation-based
286
294
// attribute can take over.
287
- else if (starts_with ($ key , '_ ' ))
295
+ else if (starts_with ($ key , '_ ' ) and ! in_array ( $ key , $ this -> expose ) )
288
296
{
289
297
$ camelKey = camel_case ($ key );
290
298
You can’t perform that action at this time.
0 commit comments