Monday, March 20, 2017

Laravel Spark cast on pivot table

I'm looking to cast a JSON field on a pivot table to an array.

I tried a custom pivot table on my User and Instrument models of my project, however because the default User model with Spark extends SparkUser I'm getting the following error when trying to implement it:

Declaration of App\Models\User::newPivot() should be compatible with Illuminate\Database\Eloquent\Model::newPivot(Illuminate\Database\Eloquent\Model $parent, array $attributes, $table, $exists, $using = NULL)

I also tried adding using dot-notation on these two models with a few variations to no avail:

'instruments.pivot.levels' => 'array',
'users.pivot.levels' => 'array',

I'm using:

"laravel/framework": "5.4.*",
"laravel/spark": "~4.0",

Any help is appreciated, thanks!



via davidsneal

Advertisement