优化税类

This commit is contained in:
Edward Yang 2022-08-26 10:26:27 +08:00
parent 0d28e4765e
commit 2503012cd8
2 changed files with 7 additions and 2 deletions

View File

@ -19,10 +19,12 @@ class TaxClassDetail extends JsonResource
{ {
return [ return [
'id' => $this->id, 'id' => $this->id,
'name' => $this->title, 'title' => $this->title,
'description' => sub_string($this->description), 'description' => sub_string($this->description),
'created_at' => time_format($this->created_at), 'created_at' => time_format($this->created_at),
'updated_at' => time_format($this->updated_at), 'updated_at' => time_format($this->updated_at),
'tax_rates' => $this->taxRates->toArray(),
'tax_rules' => $this->taxRules->toArray(),
]; ];
} }
} }

View File

@ -11,6 +11,7 @@
namespace Beike\Admin\Repositories; namespace Beike\Admin\Repositories;
use Beike\Admin\Http\Resources\TaxClassDetail;
use Beike\Models\TaxClass; use Beike\Models\TaxClass;
class TaxClassRepo class TaxClassRepo
@ -19,10 +20,12 @@ class TaxClassRepo
public static function getList() public static function getList()
{ {
return TaxClass::query()->with([ $taxClass = TaxClass::query()->with([
'taxRates.region', 'taxRates.region',
'taxRules' 'taxRules'
])->get(); ])->get();
return TaxClassDetail::collection($taxClass)->jsonSerialize();
} }
public static function createOrUpdate($data) public static function createOrUpdate($data)