Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Entries/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ public static function makeModelFromContract(EntryContract $source)
'order' => $source->order(),
];

if ($source->template) {
$attributes['data']->put('template', $source->template);
}

foreach ($dataMappings as $key) {
$attributes[$key] = $data->get($key);
}
Expand Down
17 changes: 17 additions & 0 deletions tests/Commands/ImportEntriesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,21 @@ public function it_imports_localized_entries()
$this->assertDatabaseHas('entries', ['collection' => 'pages', 'site' => 'en', 'slug' => 'foo', 'data' => '{"foo":"bar"}']);
$this->assertDatabaseHas('entries', ['collection' => 'pages', 'site' => 'fr', 'slug' => 'foo', 'data' => '{"foo":"bar","baz":"qux","__localized_fields":[]}']);
}

#[Test]
public function it_imports_template_correctly()
{
$collection = tap(Collection::make('pages')->title('Pages'))->save();
Entry::make()->collection($collection)->slug('template-test')->data(['foo' => 'bar'])->template('some.template')->save();

$this->assertCount(0, EntryModel::all());

$this->artisan('statamic:eloquent:import-entries')
->expectsOutputToContain('Entries imported successfully.')
->assertExitCode(0);

$this->assertCount(1, EntryModel::all());

$this->assertDatabaseHas('entries', ['collection' => 'pages', 'slug' => 'template-test', 'data' => '{"foo":"bar","template":"some.template"}']);
}
}
2 changes: 1 addition & 1 deletion tests/Data/Entries/EntryQueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ public function filtering_using_where_status_column_writes_deprecation_log()
}

#[Test]
public function filtering_using_whereIn_status_column_writes_deprecation_log()
public function filtering_using_where_in_status_column_writes_deprecation_log()
{
$this->withoutDeprecationHandling();
$this->expectException(\ErrorException::class);
Expand Down