LoginSignup
1
1

More than 3 years have passed since last update.

Laravelのアプリケーション全体でCarbonImmutableを使用したい

Posted at

はじめに

こんにちは。Laravelで日に日に新しいもの出てきて(見つけて)、追いつくのに必死の筆者です :sob:

さて、Carbon使っていますでしょうか?

Eloquentの返り値等々、CarbonImmutableだったらいいなと感じました。

CarbonImmutableにできます :ok_hand:

AppServiceProviderにたった1行書くだけ :thumbsup:

AppServiceProvider.php
class AppServiceProvider extends ServiceProvider
{
    public function register()
    {
        // アプリケーション全体でCarbonImmutableを使用する.
        DateFactory::use(\Carbon\CarbonImmutable::class);
    }
}

おわりに

業務委託でぼそっと言われたのをしれっと対応した備忘録でした:pray:
それでは!

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1