浏览代码

refactor

3.x
Andrew Wallo 1年前
父节点
当前提交
bf62ce11ef

+ 1
- 25
app/DTO/AccountBalanceDTO.php 查看文件

2
 
2
 
3
 namespace App\DTO;
3
 namespace App\DTO;
4
 
4
 
5
-use Livewire\Wireable;
6
-
7
-class AccountBalanceDTO implements Wireable
5
+class AccountBalanceDTO
8
 {
6
 {
9
     public function __construct(
7
     public function __construct(
10
         public ?string $startingBalance,
8
         public ?string $startingBalance,
13
         public ?string $netMovement,
11
         public ?string $netMovement,
14
         public ?string $endingBalance,
12
         public ?string $endingBalance,
15
     ) {}
13
     ) {}
16
-
17
-    public function toLivewire(): array
18
-    {
19
-        return [
20
-            'startingBalance' => $this->startingBalance,
21
-            'debitBalance' => $this->debitBalance,
22
-            'creditBalance' => $this->creditBalance,
23
-            'netMovement' => $this->netMovement,
24
-            'endingBalance' => $this->endingBalance,
25
-        ];
26
-    }
27
-
28
-    public static function fromLivewire($value): static
29
-    {
30
-        return new static(
31
-            $value['startingBalance'],
32
-            $value['debitBalance'],
33
-            $value['creditBalance'],
34
-            $value['netMovement'],
35
-            $value['endingBalance'],
36
-        );
37
-    }
38
 }
14
 }

+ 1
- 19
app/DTO/AccountCategoryDTO.php 查看文件

2
 
2
 
3
 namespace App\DTO;
3
 namespace App\DTO;
4
 
4
 
5
-use Livewire\Wireable;
6
-
7
-class AccountCategoryDTO implements Wireable
5
+class AccountCategoryDTO
8
 {
6
 {
9
     /**
7
     /**
10
      * @param  AccountDTO[]  $accounts
8
      * @param  AccountDTO[]  $accounts
13
         public array $accounts,
11
         public array $accounts,
14
         public AccountBalanceDTO $summary,
12
         public AccountBalanceDTO $summary,
15
     ) {}
13
     ) {}
16
-
17
-    public function toLivewire(): array
18
-    {
19
-        return [
20
-            'accounts' => $this->accounts,
21
-            'summary' => $this->summary->toLivewire(),
22
-        ];
23
-    }
24
-
25
-    public static function fromLivewire($value): static
26
-    {
27
-        return new static(
28
-            $value['accounts'],
29
-            AccountBalanceDTO::fromLivewire($value['summary']),
30
-        );
31
-    }
32
 }
14
 }

+ 1
- 23
app/DTO/AccountDTO.php 查看文件

2
 
2
 
3
 namespace App\DTO;
3
 namespace App\DTO;
4
 
4
 
5
-use Livewire\Wireable;
6
-
7
-class AccountDTO implements Wireable
5
+class AccountDTO
8
 {
6
 {
9
     public function __construct(
7
     public function __construct(
10
         public string $accountName,
8
         public string $accountName,
12
         public ?int $accountId,
10
         public ?int $accountId,
13
         public AccountBalanceDTO $balance,
11
         public AccountBalanceDTO $balance,
14
     ) {}
12
     ) {}
15
-
16
-    public function toLivewire(): array
17
-    {
18
-        return [
19
-            'accountName' => $this->accountName,
20
-            'accountCode' => $this->accountCode,
21
-            'accountId' => $this->accountId,
22
-            'balance' => $this->balance->toLivewire(),
23
-        ];
24
-    }
25
-
26
-    public static function fromLivewire($value): static
27
-    {
28
-        return new static(
29
-            $value['accountName'],
30
-            $value['accountCode'],
31
-            $value['accountId'],
32
-            AccountBalanceDTO::fromLivewire($value['balance']),
33
-        );
34
-    }
35
 }
13
 }

+ 1
- 21
app/DTO/ReportDTO.php 查看文件

2
 
2
 
3
 namespace App\DTO;
3
 namespace App\DTO;
4
 
4
 
5
-use Livewire\Wireable;
6
-
7
-class ReportDTO implements Wireable
5
+class ReportDTO
8
 {
6
 {
9
     public function __construct(
7
     public function __construct(
10
         /**
8
         /**
14
         public ?AccountBalanceDTO $overallTotal = null,
12
         public ?AccountBalanceDTO $overallTotal = null,
15
         public array $fields = [],
13
         public array $fields = [],
16
     ) {}
14
     ) {}
17
-
18
-    public function toLivewire(): array
19
-    {
20
-        return [
21
-            'categories' => $this->categories,
22
-            'overallTotal' => $this->overallTotal?->toLivewire(),
23
-            'fields' => $this->fields,
24
-        ];
25
-    }
26
-
27
-    public static function fromLivewire($value): static
28
-    {
29
-        return new static(
30
-            $value['categories'],
31
-            isset($value['overallTotal']) ? AccountBalanceDTO::fromLivewire($value['overallTotal']) : null,
32
-            $value['fields'] ?? [],
33
-        );
34
-    }
35
 }
15
 }

+ 1
- 16
app/Transformers/BaseReportTransformer.php 查看文件

5
 use App\Contracts\ExportableReport;
5
 use App\Contracts\ExportableReport;
6
 use App\DTO\ReportDTO;
6
 use App\DTO\ReportDTO;
7
 use Filament\Support\Enums\Alignment;
7
 use Filament\Support\Enums\Alignment;
8
-use Livewire\Wireable;
9
 
8
 
10
-abstract class BaseReportTransformer implements ExportableReport, Wireable
9
+abstract class BaseReportTransformer implements ExportableReport
11
 {
10
 {
12
     protected ReportDTO $report;
11
     protected ReportDTO $report;
13
 
12
 
40
 
39
 
41
         return 'text-left';
40
         return 'text-left';
42
     }
41
     }
43
-
44
-    public function toLivewire(): array
45
-    {
46
-        return [
47
-            'report' => $this->report->toLivewire(),
48
-        ];
49
-    }
50
-
51
-    public static function fromLivewire($value): static
52
-    {
53
-        return new static(
54
-            ReportDTO::fromLivewire($value['report']),
55
-        );
56
-    }
57
 }
42
 }

正在加载...
取消
保存