diff --git a/src/Sushi.php b/src/Sushi.php index 0c9b941..0b72544 100644 --- a/src/Sushi.php +++ b/src/Sushi.php @@ -136,7 +136,7 @@ public function migrate() if (count($this->casts) > 0) { foreach ($rows as $row) { // If $casts are present, use Eloquent's "create" instead of a plain insert so they are used and applied... - static::forceCreate($row); + static::make()->setRawAttributes($row)->save(); } } else { foreach (array_chunk($rows, $this->getSushiInsertChunkSize()) ?? [] as $inserts) { diff --git a/tests/SushiTest.php b/tests/SushiTest.php index aad9b73..cc4f56e 100644 --- a/tests/SushiTest.php +++ b/tests/SushiTest.php @@ -393,7 +393,9 @@ class ModelWithCasts extends Model 'is_boolean' => 'boolean', ]; - protected $rows = [ - ['is_array' => [1, 2, 3], 'is_boolean' => true], - ]; + protected function getRows() { + return [ + ['is_array' => json_encode([1, 2, 3]), 'is_boolean' => true], + ]; + } }