From d0f136e4845edb8f674fb59b16a688dfb15a92a3 Mon Sep 17 00:00:00 2001 From: stasbilay02 Date: Thu, 8 Aug 2024 16:31:26 +0300 Subject: [PATCH] add formats --- examples/simple.json | 1 + examples/simple.php | 3 +++ src/FormatMapper.php | 4 ++++ src/formats/HtmlFormat.php | 14 ++++++++++++++ src/formats/PhoneNumberFormat.php | 14 ++++++++++++++ 5 files changed, 36 insertions(+) create mode 100644 src/formats/HtmlFormat.php create mode 100644 src/formats/PhoneNumberFormat.php diff --git a/examples/simple.json b/examples/simple.json index e0a7b9c..82aa9a4 100644 --- a/examples/simple.json +++ b/examples/simple.json @@ -6,6 +6,7 @@ "email": "Email", "created_at": "Дата создания", "description": "Описание 1", + "description2": "Описание 2", "status": "Статус" }, "actions": ["view"], diff --git a/examples/simple.php b/examples/simple.php index e4b5568..bccc66b 100644 --- a/examples/simple.php +++ b/examples/simple.php @@ -12,6 +12,9 @@ $table->columns([ "created_at" => [ "format" => "date:Y-m-d", ], + 'description2' => [ + "format" => "html:", + ], 'status' => function ($cell) { return getStatusLabel()[$cell]; }, diff --git a/src/FormatMapper.php b/src/FormatMapper.php index 7e0ca29..7ade4d2 100644 --- a/src/FormatMapper.php +++ b/src/FormatMapper.php @@ -3,6 +3,8 @@ namespace Itguild\Tables; use Itguild\Tables\formats\DateFormat; +use Itguild\Tables\formats\HtmlFormat; +use Itguild\Tables\formats\PhoneNumberFormat; use Itguild\Tables\formats\TextFormat; class FormatMapper @@ -13,6 +15,8 @@ class FormatMapper return [ 'text' => TextFormat::class, 'date' => DateFormat::class, + 'html' => HtmlFormat::class, + 'phoneNumber' => PhoneNumberFormat::class, ]; } diff --git a/src/formats/HtmlFormat.php b/src/formats/HtmlFormat.php new file mode 100644 index 0000000..fabef97 --- /dev/null +++ b/src/formats/HtmlFormat.php @@ -0,0 +1,14 @@ +