From 01e77cb807572285cf4b4720b34040427c972613 Mon Sep 17 00:00:00 2001 From: Deon George Date: Sun, 7 Jul 2024 11:50:57 +1000 Subject: [PATCH] Added LeenooksCarbon cast class --- src/Casts/LeenooksCarbon.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/Casts/LeenooksCarbon.php diff --git a/src/Casts/LeenooksCarbon.php b/src/Casts/LeenooksCarbon.php new file mode 100644 index 0000000..fb8de5a --- /dev/null +++ b/src/Casts/LeenooksCarbon.php @@ -0,0 +1,29 @@ + $attributes + */ + public function get(Model $model, string $key, mixed $value, array $attributes): mixed + { + return \Leenooks\Carbon::create($value); + } + + /** + * Prepare the given value for storage. + * + * @param array $attributes + */ + public function set(Model $model, string $key, mixed $value, array $attributes): mixed + { + return $value->format('Y-m-d H:i:s'); + } +}