Commit cca9a2a8 authored by Jesse O'Brien's avatar Jesse O'Brien

Adding a check for exposable json attributes.

parent 44f9eebc
...@@ -28,6 +28,14 @@ abstract class Model extends \Jenssegers\Eloquent\Model { ...@@ -28,6 +28,14 @@ abstract class Model extends \Jenssegers\Eloquent\Model {
*/ */
protected $primaryKey = '_id'; protected $primaryKey = '_id';
/**
* Allow json attributes to be exposable. This is mainly for
* relations that can be kept alive in a toJson()
*
* @var array
*/
protected $exposeJsonAttributes = [];
/** /**
* The connection resolver instance. * The connection resolver instance.
* *
...@@ -284,7 +292,7 @@ abstract class Model extends \Jenssegers\Eloquent\Model { ...@@ -284,7 +292,7 @@ abstract class Model extends \Jenssegers\Eloquent\Model {
// internal array of embedded documents. In that case, we need // internal array of embedded documents. In that case, we need
// to hide these from the output so that the relation-based // to hide these from the output so that the relation-based
// attribute can take over. // attribute can take over.
else if (starts_with($key, '_')) else if (starts_with($key, '_') and ! in_array($key, $this->exposeJsonAttributes))
{ {
$camelKey = camel_case($key); $camelKey = camel_case($key);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment