success( Assistant::whereUserId($request->user('api')->id)->get() ); } /** * Store a newly created resource in storage. */ public function store(Request $request) { $request->validate([ 'name' => 'string|required', 'description' => 'string|required', 'prompt' => 'string|required|max:2000', ]); $assistantModel = new Assistant(); $assistant = $assistantModel->create([ 'name' => $request->input('name'), 'description' => $request->input('description'), 'prompt' => $request->input('prompt'), 'user_id' => $request->user('api')->id, ]); // $tools = $request->input('tools'); // 检测这些工具是否存在且是否属于用户 // $tools = $assistantModel->whereIn('id', $tools)->whereUserId($request->user('api')->id)->get(); // // $assistant->tools()->sync($tools->pluck('id')->toArray()); // // // $assistant->tools()->sync($request->input('tools')); return $this->created($assistant); } /** * Display the specified resource. */ public function show(AssistantRequest $request, Assistant $assistant) { // } /** * Update the specified resource in storage. */ public function update(AssistantRequest $request, Assistant $assistant) { // } /** * Remove the specified resource from storage. */ public function destroy(AssistantRequest $request, Assistant $assistant) { // } }