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 {
2828 */
2929 protected $ primaryKey = '_id ' ;
3030
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+
3139 /**
3240 * The connection resolver instance.
3341 *
@@ -284,7 +292,7 @@ public function attributesToArray()
284292 // internal array of embedded documents. In that case, we need
285293 // to hide these from the output so that the relation-based
286294 // attribute can take over.
287- else if (starts_with ($ key , '_ ' ))
295+ else if (starts_with ($ key , '_ ' ) and ! in_array ( $ key , $ this -> expose ) )
288296 {
289297 $ camelKey = camel_case ($ key );
290298
You can’t perform that action at this time.
0 commit comments