Fixed api issue

This commit is contained in:
m.razaghi
2026-07-16 14:58:11 +03:30
parent a6ae5724f6
commit 209b1f2530
3 changed files with 20 additions and 20 deletions

View File

@@ -14,19 +14,19 @@ class BylawNoteController extends Controller
public function create(Request $request)
{
$validated = $request->validate([
'bylaw_document_id' => 'required',
'bylaw_id' => 'required', // Cleaned up for the frontend!
'note' => 'required',
'color_code' => 'nullable',
]);
BylawNote::query()->create([
'user_id' => auth()->user()->id,
'bylaw_document_id' => $validated['bylaw_document_id'],
'user_id' => auth()->id(),
'bylaw_document_id' => $validated['bylaw_id'], // Maps perfectly to the DB
'note' => $validated['note'],
'color_code' => $validated['color_code'],
]);
return $this->success([], 'با موفقیت اضافه شد');
return $this->success([], 'موفق', 'یادداشت با موفقیت اضافه شد');
}
public function update($id, Request $request)
@@ -36,20 +36,21 @@ class BylawNoteController extends Controller
'color_code' => 'nullable',
]);
$note = BylawNote::findOrFail($id);
$note = BylawNote::where('user_id', auth()->id())->findOrFail($id);
$note->update([
'note' => $validated['note'],
'color_code' => $validated['color_code'],
]);
return $this->success([], 'بروز شد');
return $this->success([], 'بروزرسانی', 'یادداشت با موفقیت بروزرسانی شد');
}
public function destroy($id)
{
$note = BylawNote::findOrFail($id);
$note = BylawNote::where('user_id', auth()->id())->findOrFail($id);
$note->delete();
return $this->success([], 'حذف شد');
return $this->success([], 'حذف', 'یادداشت با موفقیت حذف شد');
}
}