|
|
|
@ -13,6 +13,9 @@ use Illuminate\Database\Eloquent\Builder; |
|
|
|
|
*/ |
|
|
|
|
class Row extends BaseModel |
|
|
|
|
{ |
|
|
|
|
protected static $noCasts = false; |
|
|
|
|
protected static $noCastsStack = []; |
|
|
|
|
|
|
|
|
|
protected $casts = [ |
|
|
|
|
'data' => 'object', |
|
|
|
|
]; |
|
|
|
@ -20,6 +23,25 @@ class Row extends BaseModel |
|
|
|
|
protected $guarded = []; |
|
|
|
|
public $timestamps = false; |
|
|
|
|
|
|
|
|
|
public static function disableCasts() |
|
|
|
|
{ |
|
|
|
|
array_push(self::$noCastsStack, self::$noCasts); |
|
|
|
|
self::$noCasts = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static function enableCasts() |
|
|
|
|
{ |
|
|
|
|
self::$noCasts = array_pop(self::$noCastsStack); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getCasts() |
|
|
|
|
{ |
|
|
|
|
// This override is needed to prevent casting 'id' to int when it occurs |
|
|
|
|
// as a field in a result of the rowData query |
|
|
|
|
// (this caused display of zeros in string cols) |
|
|
|
|
return self::$noCasts ? [] : $this->casts; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getRowIdAttribute() { |
|
|
|
|
return $this->data->_id; |
|
|
|
|
} |
|
|
|
|