*/ public function index(): array { $paginator = PromptTemplate::with('user') ->latest() ->paginate(15); return [ 'data' => $paginator->items(), 'total' => $paginator->total(), 'per_page' => $paginator->perPage(), 'current_page' => $paginator->currentPage(), 'last_page' => $paginator->lastPage(), 'from' => $paginator->firstItem(), 'to' => $paginator->lastItem(), ]; } /** * Store a newly created resource in storage. */ public function store(array $data): PromptTemplate { $data['user_id'] = auth()->id(); return PromptTemplate::create($data); } /** * Update the specified resource in storage. */ public function update(PromptTemplate $template, array $data): PromptTemplate { $template->update($data); return $template; } /** * Remove the specified resource from storage. */ public function destroy(PromptTemplate $template): bool { try { $template->delete(); return true; } catch (RuntimeException $e) { Log::error('Failed to delete prompt template: ' . $e->getMessage()); return false; } } }