A Laravel Carbon null-class.

Fund package maintenance!

Installs: 59 045

Dependents: 0

Suggesters: 0

Security: 0

Stars: 27

Watchers: 2

Forks: 0

10.0.0 2023-05-20 20:08 UTC

This package is auto-updated.

Last update: 2024-02-20 21:41:58 UTC


NUll-Carbon for Laravel masthead image.


Methods should always return only one data-type. This principle is broken if a method returns both null and some other data-type, so the solution is to return a null-class. The NullCarbon class is a null-class implementation of Laravel's Carbon class.


  • PHP >= 7.1.3
  • Laravel >= 5.5


composer require genealabs/laravel-null-carbon


The following is an example of how to use the NullCarbon class for date fields on a model:

use GeneaLabs\LaravelNullCarbon\NullCarbon;
use Illuminate\Support\Carbon;

class MyModel
    protected $dates = [

    public function getPublishedAtAttribute() : Carbon
        return $this->published_at
            ?: new NullCarbon;

The Fine Print

Commitment to Quality

During package development I try as best as possible to embrace good design and development practices to try to ensure that this package is as good as it can be. My checklist for package development includes:

  • ✅ Achieve as close to 100% code coverage as possible using unit tests.
  • ✅ Eliminate any issues identified by SensioLabs Insight and Scrutinizer.
  • ✅ Be fully PSR1, PSR2, and PSR4 compliant.
  • ✅ Include comprehensive documentation in
  • ✅ Provide an up-to-date which adheres to the format outlined at
  • ✅ Have no PHPMD or PHPCS warnings throughout all code.


Please observe and respect all aspects of the included Code of Conduct

Reporting Issues

When reporting issues, please fill out the included template as completely as possible. Incomplete issues may be ignored or closed if there is not enough information included to be actionable.

Submitting Pull Requests

Please review the Contribution Guidelines Only PRs that meet all criterium will be accepted.

❤️ Open-Source Software - Give ⭐️

We have included the awesome symfony/thanks composer package as a dev dependency. Let your OS package maintainers know you appreciate them by starring the packages you use. Simply run composer thanks after installing this package. (And not to worry, since it's a dev-dependency it won't be installed in your live environment.)