Skip to content

Commit

Permalink
Fix import issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanmitchell committed Dec 9, 2024
1 parent 6a39960 commit fc993b8
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Commands/ImportForms.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@
use Illuminate\Support\Facades\Facade;
use Statamic\Console\RunsInPlease;
use Statamic\Contracts\Forms\Form as FormContract;
use Statamic\Contracts\Forms\FormRepository as FormRepositoryContract;
use Statamic\Contracts\Forms\Submission as SubmissionContract;
use Statamic\Contracts\Forms\SubmissionRepository as SubmissionRepositoryContract;
use Statamic\Eloquent\Forms\Form;
use Statamic\Facades\File;
use Statamic\Forms\Form as StacheForm;
use Statamic\Forms\FormRepository;
use Statamic\Forms\Submission as StacheSubmission;
use Statamic\Stache\Repositories\SubmissionRepository;

class ImportForms extends Command
{
Expand Down Expand Up @@ -50,11 +53,15 @@ public function handle(): int
private function useDefaultRepositories(): void
{
Facade::clearResolvedInstance(FormContract::class);
Facade::clearResolvedInstance(FormRepositoryContract::class);
Facade::clearResolvedInstance(SubmissionContract::class);
Facade::clearResolvedInstance(SubmissionRepositoryContract::class);

app()->bind(FormContract::class, StacheForm::class);
app()->bind(FormRepositoryContract::class, FormRepository::class);
app()->bind(SubmissionContract::class, StacheSubmission::class);
app()->bind(\Statamic\Eloquent\Forms\SubmissionQueryBuilder::class, \Statamic\Stache\Query\SubmissionQueryBuilder::class);
app()->bind(SubmissionRepositoryContract::class, SubmissionRepository::class);
app()->bind(\Statamic\Contracts\Forms\SubmissionQueryBuilder::class, \Statamic\Stache\Query\SubmissionQueryBuilder::class);
}

private function importForms(): void
Expand All @@ -72,7 +79,7 @@ private function importForms(): void
}

if ($shouldImportSubmissions) {
$form->submissions()->each(function ($submission) use ($form) {
$form->querySubmissions()->lazy()->each(function ($submission) use ($form) {
$timestamp = app('statamic.eloquent.form_submissions.model')::make()->fromDateTime($submission->date());

app('statamic.eloquent.form_submissions.model')::firstOrNew(['created_at' => $timestamp])
Expand Down

0 comments on commit fc993b8

Please sign in to comment.