Fixed api issue
This commit is contained in:
@@ -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([], 'حذف', 'یادداشت با موفقیت حذف شد');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,19 +14,19 @@ class JudicialPrecedentNoteController extends Controller
|
||||
public function create(Request $request)
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'judicial_precedent_id' => 'required',
|
||||
'judicial_id' => 'required', // Cleaned up!
|
||||
'note' => 'required',
|
||||
'color_code' => 'nullable',
|
||||
]);
|
||||
|
||||
JudicialPrecedentNote::query()->create([
|
||||
'user_id' => auth()->id(),
|
||||
'judicial_precedent_id' => $validated['judicial_precedent_id'],
|
||||
'judicial_precedent_id' => $validated['judicial_id'], // Maps to DB
|
||||
'note' => $validated['note'],
|
||||
'color_code' => $validated['color_code'],
|
||||
]);
|
||||
|
||||
return $this->success([], 'با موفقیت اضافه شد');
|
||||
return $this->success([], 'موفق', 'یادداشت با موفقیت اضافه شد');
|
||||
}
|
||||
|
||||
public function update($id, Request $request)
|
||||
@@ -36,7 +36,6 @@ class JudicialPrecedentNoteController extends Controller
|
||||
'color_code' => 'nullable',
|
||||
]);
|
||||
|
||||
// SECURITY FIX: Only allow the owner of the note to update it
|
||||
$note = JudicialPrecedentNote::where('user_id', auth()->id())->findOrFail($id);
|
||||
|
||||
$note->update([
|
||||
@@ -44,7 +43,7 @@ class JudicialPrecedentNoteController extends Controller
|
||||
'color_code' => $validated['color_code'],
|
||||
]);
|
||||
|
||||
return $this->success([], 'بروز شد');
|
||||
return $this->success([], 'بروزرسانی', 'یادداشت با موفقیت بروزرسانی شد');
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
@@ -52,6 +51,6 @@ class JudicialPrecedentNoteController extends Controller
|
||||
$note = JudicialPrecedentNote::where('user_id', auth()->id())->findOrFail($id);
|
||||
$note->delete();
|
||||
|
||||
return $this->success([], 'حذف شد');
|
||||
return $this->success([], 'حذف', 'یادداشت با موفقیت حذف شد');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,19 +14,19 @@ class LegalOpinionNoteController extends Controller
|
||||
public function create(Request $request)
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'legal_opinion_id' => 'required',
|
||||
'opinion_id' => 'required', // Cleaned up!
|
||||
'note' => 'required',
|
||||
'color_code' => 'nullable',
|
||||
]);
|
||||
|
||||
LegalOpinionNote::query()->create([
|
||||
'user_id' => auth()->id(), // Cleaner way to get the user ID
|
||||
'legal_opinion_id' => $validated['legal_opinion_id'],
|
||||
'user_id' => auth()->id(),
|
||||
'legal_opinion_id' => $validated['opinion_id'], // Maps to DB
|
||||
'note' => $validated['note'],
|
||||
'color_code' => $validated['color_code'],
|
||||
]);
|
||||
|
||||
return $this->success([], 'با موفقیت اضافه شد');
|
||||
return $this->success([], 'موفق', 'یادداشت با موفقیت اضافه شد');
|
||||
}
|
||||
|
||||
public function update($id, Request $request)
|
||||
@@ -43,7 +43,7 @@ class LegalOpinionNoteController extends Controller
|
||||
'color_code' => $validated['color_code'],
|
||||
]);
|
||||
|
||||
return $this->success([], 'بروز شد');
|
||||
return $this->success([], 'بروزرسانی', 'یادداشت با موفقیت بروزرسانی شد');
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
@@ -51,6 +51,6 @@ class LegalOpinionNoteController extends Controller
|
||||
$note = LegalOpinionNote::where('user_id', auth()->id())->findOrFail($id);
|
||||
$note->delete();
|
||||
|
||||
return $this->success([], 'حذف شد');
|
||||
return $this->success([], 'حذف', 'یادداشت با موفقیت حذف شد');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user