Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BadMethodCallException: Undefined Method 'toModel()' in Statamic Forms Export Command #388

Closed
emran-alhaddad opened this issue Dec 9, 2024 · 6 comments · Fixed by #390
Closed
Labels
bug Something isn't working

Comments

@emran-alhaddad
Copy link

emran-alhaddad commented Dec 9, 2024

Bug description

Running the command php please eloquent:export-forms results in a BadMethodCallException. The error message indicates an undefined method: Statamic\Forms\Submission::toModel().

What did you expect to happen?
The forms should be exported successfully without any errors.

Error Output:

BadMethodCallException 

Call to undefined method Statamic\Forms\Submission::toModel()

at vendor/statamic/cms/src/Data/HasAugmentedInstance.php:133
    129▕         if (Compare::isQueryBuilder($value)) {
    130▕             return $value;
    131▕         }
    132▕ 
  ➜ 133▕         throw new BadMethodCallException(sprintf('Call to undefined method %s::%s()', static::class, $method));
    134▕     }
    135▕ 
    136▕     #[\ReturnTypeWillChange]
    137▕     public function offsetGet($key)

      +24 vendor frames 

  25  please:18
      Illuminate\Foundation\Application::handleCommand()

How to reproduce

  1. Navigate to your project directory.
  2. Run the following command: php please eloquent:export-forms
  3. Observe the BadMethodCallException error.

Logs

No response

Environment

Environment
Application Name: ****
Laravel Version: 11.34.2
PHP Version: 8.2.22
Composer Version: 2.5.5
Environment: production
Debug Mode: ENABLED
URL: ***
Maintenance Mode: OFF
Timezone: UTC
Locale: en

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: file
Database: mysql
Logs: stack / single
Mail: smtp
Queue: sync
Session: file

Statamic
Addons: 3
Sites: 2 (Arabic, English)
Stache Watcher: Enabled
Static Caching: Disabled
Version: 5.42.0 PRO

Statamic Addons
isaadsalman/headless-refresh: 1.0.0
ndx/statamic-bard-color-picker: 2.0.0
statamic/eloquent-driver: 4.19.0

Statamic Eloquent Driver
Asset Containers: eloquent
Assets: eloquent
Blueprints: eloquent
Collection Trees: eloquent
Collections: eloquent
Entries: eloquent
Forms: eloquent
Global Sets: eloquent
Global Variables: eloquent
Navigation Trees: eloquent
Navigations: eloquent
Revisions: file
Sites: eloquent
Taxonomies: eloquent
Terms: eloquent
Tokens: eloquent

Additional details

No response

@emran-alhaddad emran-alhaddad added the bug Something isn't working label Dec 9, 2024
@ryanmitchell
Copy link
Contributor

I'm not seeing this on my test install.

Can you share the entire stack trace of your error, inside backticks (``) please? You've only given the first part of the error.

@duncanmcclean
Copy link
Member

I've just fixed the snippet you provided. Like Ryan says, please surround any code/stack traces with three backticks (`) at the start & end, otherwise it's really hard to read.

@emran-alhaddad
Copy link
Author

@ryanmitchell @duncanmcclean

Thank you for your feedback. Due to security policies, I am unable to share the entire stack trace. However, I can provide specific parts of the error or any relevant details that may help with troubleshooting. Let me know if you'd like me to proceed this way.

@duncanmcclean
Copy link
Member

Are you able to provide the stack trace but remove any references to the project?

@emran-alhaddad
Copy link
Author

@duncanmcclean
This is a complete log for same project locally from log file I removed sensitive info. please tell me if this is enough or still need anything else

[2024-12-09 14:18:39] locale.ERROR: Call to undefined method Statamic\Forms\Submission::toModel() {"exception":"[object] (BadMethodCallException(code: 0): Call to undefined method Statamic\\Forms\\Submission::toModel() at /EmranPc/project/vendor/statamic/cms/src/Data/HasAugmentedInstance.php:133)
[stacktrace]
#0 /EmranPc/project/vendor/statamic/eloquent-driver/src/Forms/SubmissionRepository.php(13): Statamic\\Forms\\Submission->__call('toModel', Array)
#1 /EmranPc/project/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(357): Statamic\\Eloquent\\Forms\\SubmissionRepository->save(Object(Statamic\\Forms\\Submission))
#2 /EmranPc/project/vendor/statamic/cms/src/Forms/Submission.php(173): Illuminate\\Support\\Facades\\Facade::__callStatic('save', Array)
#3 /EmranPc/project/vendor/statamic/eloquent-driver/src/Commands/ExportForms.php(95): Statamic\\Forms\\Submission->save()
#4 /EmranPc/project/vendor/laravel/framework/src/Illuminate/Collections/Traits/EnumeratesValues.php(257): Statamic\\Eloquent\\Commands\\ExportForms->Statamic\\Eloquent\\Commands\\{closure}(Object(Statamic\\Eloquent\\Forms\\Submission), 0)
#5 /EmranPc/project/vendor/statamic/eloquent-driver/src/Commands/ExportForms.php(86): Illuminate\\Support\\Collection->each(Object(Closure))
#6 /EmranPc/project/vendor/laravel/framework/src/Illuminate/Console/Concerns/InteractsWithIO.php(267): Statamic\\Eloquent\\Commands\\ExportForms->Statamic\\Eloquent\\Commands\\{closure}(Object(Statamic\\Eloquent\\Forms\\Form), Object(Symfony\\Component\\Console\\Helper\\ProgressBar))
#7 /EmranPc/project/vendor/statamic/eloquent-driver/src/Commands/ExportForms.php(72): Illuminate\\Console\\Command->withProgressBar(Object(Illuminate\\Support\\Collection), Object(Closure))
#8 /EmranPc/project/vendor/statamic/eloquent-driver/src/Commands/ExportForms.php(46): Statamic\\Eloquent\\Commands\\ExportForms->exportForms()
#9 /EmranPc/project/vendor/statamic/eloquent-driver/src/Commands/ExportForms.php(63): Statamic\\Eloquent\\Commands\\ExportForms->Statamic\\Eloquent\\Commands\\{closure}()
#10 /EmranPc/project/vendor/statamic/eloquent-driver/src/Commands/ExportForms.php(45): Statamic\\Eloquent\\Commands\\ExportForms->usingDefaultRepositories(Object(Closure))
#11 /EmranPc/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Statamic\\Eloquent\\Commands\\ExportForms->handle()
#12 /EmranPc/project/vendor/laravel/framework/src/Illuminate/Container/Util.php(43): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#13 /EmranPc/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(95): Illuminate\\Container\\Util::unwrapIfClosure(Object(Closure))
#14 /EmranPc/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(35): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Array, Object(Closure))
#15 /EmranPc/project/vendor/laravel/framework/src/Illuminate/Container/Container.php(690): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Array, Array, NULL)
#16 /EmranPc/project/vendor/laravel/framework/src/Illuminate/Console/Command.php(213): Illuminate\\Container\\Container->call(Array)
#17 /EmranPc/project/vendor/symfony/console/Command/Command.php(279): Illuminate\\Console\\Command->execute(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#18 /EmranPc/project/vendor/laravel/framework/src/Illuminate/Console/Command.php(182): Symfony\\Component\\Console\\Command\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#19 /EmranPc/project/vendor/symfony/console/Application.php(1047): Illuminate\\Console\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#20 /EmranPc/project/vendor/symfony/console/Application.php(316): Symfony\\Component\\Console\\Application->doRunCommand(Object(Statamic\\Eloquent\\Commands\\ExportForms), Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#21 /EmranPc/project/vendor/symfony/console/Application.php(167): Symfony\\Component\\Console\\Application->doRun(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#22 /EmranPc/project/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(197): Symfony\\Component\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#23 /EmranPc/project/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1203): Illuminate\\Foundation\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#24 /EmranPc/project/please(18): Illuminate\\Foundation\\Application->handleCommand(Object(Symfony\\Component\\Console\\Input\\ArgvInput))
#25 {main}
"} 

@ryanmitchell
Copy link
Contributor

The same PR should fix this - #390

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants