mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-15 04:10:51 +08:00
feat(knowledge): add KnowledgeResource with plugin hooks
- Add KnowledgeResource with user.knowledge.resource hook - Unify processKnowledgeContent for both single and list items - Remove isListItem parameter for cleaner architecture
This commit is contained in:
28
app/Http/Resources/KnowledgeResource.php
Normal file
28
app/Http/Resources/KnowledgeResource.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user