mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-15 04:10:51 +08:00
- Add KnowledgeResource with user.knowledge.resource hook - Unify processKnowledgeContent for both single and list items - Remove isListItem parameter for cleaner architecture
29 lines
669 B
PHP
29 lines
669 B
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
use App\Services\Plugin\HookManager;
|
|
|
|
class KnowledgeResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function toArray(Request $request): array
|
|
{
|
|
$data = [
|
|
'id' => $this['id'],
|
|
'category' => $this['category'],
|
|
'title' => $this['title'],
|
|
'body' => $this->when(isset($this['body']), $this['body']),
|
|
'updated_at' => $this['updated_at'],
|
|
];
|
|
|
|
return HookManager::filter('user.knowledge.resource', $data, $request, $this);
|
|
}
|
|
}
|