add integer format
This commit is contained in:
parent
19e994ef38
commit
96b249eb51
@ -23,8 +23,8 @@
|
|||||||
"email"
|
"email"
|
||||||
],
|
],
|
||||||
"data": [
|
"data": [
|
||||||
{"id": 1,"email":"fas1@mail.ru","description":"sdgsdfg","description2":"ffdghdas", "created_at": "17.06.2024", "status": 1},
|
{"id": 1,"email":"fas1@mail.ru","description":"sdgsdfg","description2":"ffdghdas", "created_at": "17.06.2024", "status": "1"},
|
||||||
{"id": 2,"email":"fas2@mail.ru","description":"fafdgdfgsdfdfs","description2":"ffdghdas", "created_at": "18.06.2024", "status": 1},
|
{"id": 2,"email":"fas2@mail.ru","description":"fafdgdfgsdfdfs","description2":"ffdghdas", "created_at": "18.06.2024", "status": "1"},
|
||||||
{"id": 3,"email":"fas3@mail.ru","description":"fafdgdssdfgdfs","description2":"ffdghdas", "created_at": "19.06.2024", "status": 2},
|
{"id": 3,"email":"fas3@mail.ru","description":"fafdgdssdfgdfs","description2":"ffdghdas", "created_at": "19.06.2024", "status": 2},
|
||||||
{"id": 4,"email":"fas4@mail.ru","description":"fafd <b>dsfgsd</b> vcbgdfs","description2":"ffdghdas", "created_at": "20.06.2024", "status": 1},
|
{"id": 4,"email":"fas4@mail.ru","description":"fafd <b>dsfgsd</b> vcbgdfs","description2":"ffdghdas", "created_at": "20.06.2024", "status": 1},
|
||||||
{"id": 5,"email":"fas5@mail.ru","description":"fafdgghjgfdfs","description2":"ffdghdas", "created_at": "21.06.2024", "status": 1},
|
{"id": 5,"email":"fas5@mail.ru","description":"fafdgghjgfdfs","description2":"ffdghdas", "created_at": "21.06.2024", "status": 1},
|
||||||
|
@ -7,22 +7,23 @@ use Itguild\Tables\ListJsonTable;
|
|||||||
$json = file_get_contents('simple.json');
|
$json = file_get_contents('simple.json');
|
||||||
$table = new ListJsonTable($json);
|
$table = new ListJsonTable($json);
|
||||||
|
|
||||||
//$table->columns([
|
|
||||||
$table->columns([
|
$table->columns([
|
||||||
"created_at" => [
|
"created_at" => [
|
||||||
"format" => "date:Y-m-d",
|
"format" => "date:Y-m-d"
|
||||||
],
|
],
|
||||||
'description' => [
|
'description' => [
|
||||||
"format" => "html",
|
"format" => "html",
|
||||||
"style" => ["width" => "300px"],
|
"style" => ["width" => "300px"],
|
||||||
"filter" => '',
|
"filter" => function () {},
|
||||||
"value" => function ($cell) {
|
"value" => function ($cell) {
|
||||||
return "<span style='color: sienna'>$cell</span>";
|
return "<span style='color: sienna'>$cell</span>";
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
'status' => function ($cell) {
|
'status' => [
|
||||||
return getStatusLabel()[$cell];
|
"format" => "integer",
|
||||||
},
|
"value" => function ($cell) {
|
||||||
|
return getStatusLabel()[$cell];
|
||||||
|
}],
|
||||||
'email' => function ($cell) {
|
'email' => function ($cell) {
|
||||||
return "<span style='color: aqua'>$cell</span>";
|
return "<span style='color: aqua'>$cell</span>";
|
||||||
},
|
},
|
||||||
|
@ -4,6 +4,7 @@ namespace Itguild\Tables;
|
|||||||
|
|
||||||
use Itguild\Tables\formats\DateFormat;
|
use Itguild\Tables\formats\DateFormat;
|
||||||
use Itguild\Tables\formats\HtmlFormat;
|
use Itguild\Tables\formats\HtmlFormat;
|
||||||
|
use Itguild\Tables\formats\IntegerFormat;
|
||||||
use Itguild\Tables\formats\PhoneNumberFormat;
|
use Itguild\Tables\formats\PhoneNumberFormat;
|
||||||
use Itguild\Tables\formats\TextFormat;
|
use Itguild\Tables\formats\TextFormat;
|
||||||
|
|
||||||
@ -17,6 +18,7 @@ class FormatMapper
|
|||||||
'date' => DateFormat::class,
|
'date' => DateFormat::class,
|
||||||
'html' => HtmlFormat::class,
|
'html' => HtmlFormat::class,
|
||||||
'phoneNumber' => PhoneNumberFormat::class,
|
'phoneNumber' => PhoneNumberFormat::class,
|
||||||
|
'integer' => IntegerFormat::class,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
14
src/formats/IntegerFormat.php
Normal file
14
src/formats/IntegerFormat.php
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Itguild\Tables\formats;
|
||||||
|
|
||||||
|
use Itguild\Tables\formats\BaseFormat;
|
||||||
|
|
||||||
|
class IntegerFormat extends BaseFormat
|
||||||
|
{
|
||||||
|
|
||||||
|
static function fetch(?string $data, string $options = "")
|
||||||
|
{
|
||||||
|
return intval($data);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user