crater icon indicating copy to clipboard operation
crater copied to clipboard

500 Error - No query results for model [Crater\Models\Currency].

Open GlitchWitch opened this issue 2 years ago • 3 comments

Describe the bug If a user deletes the initial company with company_id of 1, viewing report PDFs will result in a 500 error on all other companies.

[2022-07-30 00:03:36] production.ERROR: No query results for model [Crater\Models\Currency]. (View: /home/billing/billing.[redacted].com/resources/views/app/pdf/reports/sales-customers.blade.php) {"view":{"view":"/home/billing/billing.[redacted].com/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php","data":[]},"userId":1,"exception":"[object] (Facade\\Ignition\\Exceptions\\ViewException(code: 0): No query results for model [Crater\\Models\\Currency]. (View: /home/billing/billing.[redacted].com/resources/views/app/pdf/reports/sales-customers.blade.php) at /home/billing/billing.[redacted].com/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:444)
[stacktrace]

This is due to the following line https://github.com/crater-invoice/crater/blob/master/app/Space/helpers.php#L133

Screenshots Screenshot_2022-07-30_00-10-48

Please complete the following information:

  • Crater version: 6.0.6, 7be59e7
  • PHP version: 8.1
  • Database type and version: MySQL 8.0

Optional info

  • OS: Ubuntu 22.04
  • Deployed with Laravel Forge with site isolation enabled

GlitchWitch avatar Jul 30 '22 00:07 GlitchWitch

Also having this issue. Did you manage to resolve it?

Surgical71 avatar Aug 17 '22 12:08 Surgical71

Also having this issue. Did you manage to resolve it?

Since this happened on a freshly deployed install with nearly no data –and since I only needed one company– I just cleared the database and started over.

With that said I spun up a test server to see if changing all the company_id entries in the DB back to 1 would work and it did, but I would not recommend it.

GlitchWitch avatar Aug 18 '22 04:08 GlitchWitch

I think it's an on delete cascade issue but I'll take a look 👀

mohitpanjwani avatar Sep 01 '22 08:09 mohitpanjwani

Any progress on this bug?

RosiersRobin avatar Oct 13 '22 18:10 RosiersRobin