feat: note
This commit is contained in:
@@ -7,6 +7,7 @@ use App\Http\Controllers\Controller;
|
||||
use App\Models\Note;
|
||||
use App\Models\User;
|
||||
use App\Support\AgentScope;
|
||||
use App\Support\NoteContent;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -44,16 +45,16 @@ class NoteController extends Controller
|
||||
|
||||
$portal = $this->portal();
|
||||
$data = collect($paginator->items())->map(function ($row) use ($portal) {
|
||||
$content = $row->content;
|
||||
if (is_array($content)) {
|
||||
$content = json_encode($content, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
}
|
||||
$items = $row instanceof Note ? $row->items() : NoteContent::normalizeStored($row->content);
|
||||
$titles = NoteContent::titles($items, 2);
|
||||
|
||||
return [
|
||||
'id' => $row->id,
|
||||
'device_key' => $row->device_key ?: '',
|
||||
'channel_id' => $row->device_channel_id ?: '',
|
||||
'content' => $content ?: '',
|
||||
'item_count' => count($items),
|
||||
'preview' => implode(' · ', $titles),
|
||||
'items' => $items,
|
||||
'created_at' => optional($row->created_at)->format('Y-m-d H:i:s'),
|
||||
'updated_at' => optional($row->updated_at)->format('Y-m-d H:i:s'),
|
||||
'detail_url' => route($portal.'.devices.show', ['device' => $row->device_id, 'tab' => 'notes']),
|
||||
|
||||
Reference in New Issue
Block a user