Closed jarektkaczyk closed 6 years ago
No plans on adding this right now.
Why is that?
On Mon, Mar 5, 2018, 22:01 Taylor Otwell notifications@github.com wrote:
Closed #39 https://github.com/laravel/tinker/pull/39.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/laravel/tinker/pull/39#event-1504162945, or mute the thread https://github.com/notifications/unsubscribe-auth/AGm5ssyV4TknPDvdcJFNbBitb-DTWfkRks5tbUUcgaJpZM4SbTb6 .
--
Jarek Tkaczyk
from Kraków, in Singapore
Implemented by https://github.com/laravel/tinker/pull/133 in late 2021 (v2.6.2).
Hi!
This one allows adding custom and/or overriding laravel's own PsySH casters via array provided in
config('tinker.casters')
Setup
```php // config/tinker.php return [ 'casters' => [ // ordinary class-based method: Carbon\Carbon::class => 'App\Console\Casters::carbon', // or inline: Carbon\Carbon::class => function (Carbon\Carbon $carbon) { return [ 'date' => $carbon->date, 'weekday' => $carbon->format('l'), 'day_of_year' => (int) $carbon->format('z'), 'unix' => (int) $carbon->format('U'), 'diff_for_humans' => $carbon->diffForHumans(), ]; }, ], ]; ``` ```php namespace App\Console; class Casters { public static function carbon(Carbon\Carbon $carbon) { return [ 'date' => $carbon->date, 'weekday' => $carbon->format('l'), 'day_of_year' => (int) $carbon->format('z'), 'unix' => (int) $carbon->format('U'), 'diff_for_humans' => $carbon->diffForHumans(), ]; } } ```