mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-15 04:10:51 +08:00
refactor: 规范部分API接口响应格式
This commit is contained in:
25
app/Http/Resources/NodeResource.php
Normal file
25
app/Http/Resources/NodeResource.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class NodeResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this['id'],
|
||||
'name' => $this['name'],
|
||||
'rate' => $this['rate'],
|
||||
'tags' => $this['tags'],
|
||||
'is_online' => $this['is_online']
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user