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

Configurable date format #20

Merged

Conversation

rogervila
Copy link
Contributor

When using SQLServer I get a Carbon exception related to the date format.

Carbon\\Carbon::createFromFormat('Y-m-d H:i:s.u', '2020-03-03 14:1...')

This Pull Request adds the ability to specify the date format on the configuration, in order to avoid this error.

This is the full log in case you find it useful.

2020-03-03 14:10:08] local.ERROR: Data missing {"userId":1,"exception":"[object] (InvalidArgumentException(code: 0): Data missing at /var/www/vendor/nesbot/carbon/src/Carbon/Carbon.php:917)
[stacktrace]
#0 /var/www/vendor/laravel/framework/src/Illuminate/Support/DateFactory.php(216): Carbon\\Carbon::createFromFormat('Y-m-d H:i:s.u', '2020-03-03 14:1...')
#1 /var/www/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(239): Illuminate\\Support\\DateFactory->__call('createFromForma...', Array)
#2 /var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php(809): Illuminate\\Support\\Facades\\Facade::__callStatic('createFromForma...', Array)
#3 /var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php(831): Illuminate\\Database\\Eloquent\\Model->asDateTime('2020-03-03 14:1...')
#4 /var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php(576): Illuminate\\Database\\Eloquent\\Model->fromDateTime('2020-03-03 14:1...')
#5 /var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(329): Illuminate\\Database\\Eloquent\\Model->setAttribute('updated_at', '2020-03-03 14:1...')
#6 /var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(436): Illuminate\\Database\\Eloquent\\Model->fill(Array)
#7 /var/www/vendor/laravel/framework/src/Illuminate/Support/helpers.php(1124): Illuminate\\Database\\Eloquent\\Builder->Illuminate\\Database\\Eloquent\\{closure}(Object(Julienbourdeau\\RouteUsage\\RouteUsage))
#8 /var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(437): tap(Object(Julienbourdeau\\RouteUsage\\RouteUsage), Object(Closure))
#9 /var/www/vendor/laravel/framework/src/Illuminate/Support/Traits/ForwardsCalls.php(23): Illuminate\\Database\\Eloquent\\Builder->updateOrCreate(Array, Array)
#10 /var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1618): Illuminate\\Database\\Eloquent\\Model->forwardCallTo(Object(Illuminate\\Database\\Eloquent\\Builder), 'updateOrCreate', Array)
#11 /var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1630): Illuminate\\Database\\Eloquent\\Model->__call('updateOrCreate', Array)
#12 /var/www/vendor/julienbourdeau/route-usage/src/Listeners/LogRouteUsage.php(24): Illuminate\\Database\\Eloquent\\Model::__callStatic('updateOrCreate', Array)
#13 [internal function]: Julienbourdeau\\RouteUsage\\Listeners\\LogRouteUsage->handle(Object(Illuminate\\Foundation\\Http\\Events\\RequestHandled))
#14 /var/www/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(366): call_user_func_array(Array, Array)
#15 /var/www/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(196): Illuminate\\Events\\Dispatcher->Illuminate\\Events\\{closure}('Illuminate\\\\Foun...', Array)
#16 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(128): Illuminate\\Events\\Dispatcher->dispatch('Illuminate\\\\Foun...')
#17 /var/www/public/index.php(55): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#18 {main}
"}

@rogervila rogervila marked this pull request as ready for review March 12, 2020 14:23
@julienbourdeau
Copy link
Owner

Hi @rogervila,
I'm just back from a little break (just had baby), I'll check it out this week but so far, I think i'm going to merge and release it 👍

@rogervila
Copy link
Contributor Author

Hey @julienbourdeau, congratulations!! :)

If you find something that must be changed tell me and I'll update the PR.

@julienbourdeau
Copy link
Owner

Hi @rogervila,

Thanks a lot for your patience 😅

I didn't think this date format would be an issue. I definitely like your PR 👍 I'm going to merge it as-is but I think I'll make a few changes before tagging a version. I'd like to avoid having default values different places. I need to check how configuraiton is merged.

@julienbourdeau julienbourdeau merged commit 39106ba into julienbourdeau:master Jul 17, 2021
@julienbourdeau
Copy link
Owner

So Laravel don't seem to merge configurations so I think it's great, I'll just leave it this way 👍 Thanks!

@rogervila
Copy link
Contributor Author

Hi @rogervila,

Thanks a lot for your patience 😅

I didn't think this date format would be an issue. I definitely like your PR 👍 I'm going to merge it as-is but I think I'll make a few changes before tagging a version. I'd like to avoid having default values different places. I need to check how configuraiton is merged.

Hey! Thank you for merging @julienbourdeau

@rogervila rogervila deleted the rogervila-config-date-format branch July 17, 2021 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants