Comments (12)
I have a trait that I use in my BaseModel class:
<?php
namespace App\Models\Traits;
use Jenssegers\Date\Date;
trait TranslatesDates
{
/**
* Return model date attributes as a Jenssegers\Date\Date instance.
*
* @override \Illuminate\Database\Eloquent\Model
*
* @param mixed $value
*
* @return \Jenssegers\Date\Date
*/
protected function asDateTime($value)
{
return new Date(parent::asDateTime($value));
}
}
As far as I know is the easiest way.
from ideas.
@rtconner Surely providing the opportunity to remove an 'already high memory' date/time handler would be beneficial, if you see it as such a problem?
from ideas.
Carbon already supports localization http://carbon.nesbot.com/docs/#api-localization
from ideas.
I was under the impression that only worked with the Localization that was built into the package? I'm not sure if there are locales missing, but you certainly wouldn't be in a situation where you can adjust the strings for diffForHumans I'd expect?
from ideas.
I think you could set a Translator
instance manually to Carbon but actually you are right, Carbon is not very opened to changes
from ideas.
Not a fan of Carbon but had no problems using it, however I agree it's, in times, complicated and should be bindable/injectable/replacable.
from ideas.
I actually like Carbon a lot but there are instances where it would be nice to be able to extend / replace it for different purposes, but it seems baked pretty tightly, especially with Eloquent which is where you are most likely to be want to extend it I imagine.
from ideas.
Man this just seems like it would make an already high memory date/time handling even bulkier.
from ideas.
@taylorotwell What are your thoughts in regards to this?
If it's something that you think is a feasible improvement to the core, I'll set about putting together a PR.
from ideas.
See also this: https://hashnode.com/ama/with-taylor-otwell-cilmj90zh000k6t53il0rdgqp#cilx5el0u00m3gb53xbey9i1o
from ideas.
Interesting @Jeroen-G, I shall start putting together a PR then
from ideas.
Carbon has new maintainers now which may improve the quality / maintenance of the library going forward.
from ideas.
Related Issues (20)
- [Proposal] Easy way to cancel notifications at time of sending
- Rendering Blade Components Outside of Views HOT 1
- Assert that a component has rendered on a page
- Service Container | Contextual Binding of the Methods
- [REQUEST] Enable flush method from dynamoDB cache HOT 3
- [Feature] Enable flush method from dynamoDB
- [Proposal] Support AOP with php8 Attribute
- laravel join select max of joined column
- Ability to get event name which fires in Eloquent booted method HOT 1
- Make `php artisan migrate:reset` work with *-schema.dump
- Size File Validation only deals with Kilobytes
- Suggesting that ".env.testing" file be added to .gitignore HOT 2
- add native support for dev containers HOT 3
- [9.x] Rename firstOrNew() to firstOrMake()
- Set property to a config value via an Attribute HOT 1
- Add support to get more information on the job class
- Allow pausing batches
- afterCommit on Queueable Anonymous Event Listeners
- Upsert for related models
- Command option to run scheduler in a particular timezone
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ideas.