feat: add bylaw management features including documents, legal authorities, subject categories, and nodes

This commit is contained in:
2026-06-26 13:49:50 +03:30
parent 2e26bd229b
commit 9cf6957675
113 changed files with 1112 additions and 358 deletions

View File

@@ -5,7 +5,6 @@ namespace App\Http\Controllers\api;
use App\Http\Controllers\Controller;
use App\Models\Folder;
use App\Models\FolderArt;
use App\Models\Law;
use App\Traits\BaseApiResponse;
use Illuminate\Http\Request;
@@ -18,26 +17,25 @@ class FolderController extends Controller
$folder = Folder::query()->where('user_id', auth()->id())->get()
->map(function ($q) {
return [
"id" => $q->id,
"name" => $q->name,
"count_of_arts" => $q->arts->count(),
"created_at" => $q->created_at,
'id' => $q->id,
'name' => $q->name,
'count_of_arts' => $q->arts->count(),
'created_at' => $q->created_at,
];
});
return $this->success($folder);
}
public function create(Request $request)
{
$validted = $request->validate([
'name' => 'required'
'name' => 'required',
]);
Folder::create([
'user_id' => auth()->user()->id,
'name' => $validted['name']
'name' => $validted['name'],
]);
return $this->success([], 'ایجاد شد', 'پوشه با موفقیت ایجاد شد.');
@@ -47,7 +45,7 @@ class FolderController extends Controller
{
$validted = $request->validate([
'folder_id' => 'required',
'art_id' => 'required'
'art_id' => 'required',
]);
if (Folder::query()->where('id', $validted['folder_id'])->count() == 0) {
@@ -60,7 +58,7 @@ class FolderController extends Controller
FolderArt::create([
'folder_id' => $validted['folder_id'],
'art_id' => $validted['art_id']
'art_id' => $validted['art_id'],
]);
return $this->success([], 'اضافه شد', 'ارت با موفیت اضافه شد');
@@ -79,11 +77,11 @@ class FolderController extends Controller
$shortText = '';
if (strlen($text) > 50) {
$shortText = substr($text, 0, 50);
$shortText = substr($shortText, 0, strrpos($shortText, ' ')) . '...';
$shortText = substr($shortText, 0, strrpos($shortText, ' ')).'...';
} else {
$shortText = $text;
}
$isLocked = !auth()->user()->isSubscriber() && (bool) $art->law?->is_locked;
$isLocked = ! auth()->user()->isSubscriber() && (bool) $art->law?->is_locked;
return [
'id' => $art->id,
@@ -138,15 +136,17 @@ class FolderController extends Controller
return $this->failed('پوشه یافت نشد', 'پوشه مورد نظر یافت نشد', 404);
}
Folder::query()->where('id', $id)->delete();
return $this->success([], 'حذف شد', 'پوشه با موفقیت حذف شد');
}
public function delete_art($id,$art_id)
public function delete_art($id, $art_id)
{
if (FolderArt::query()->where('folder_id', $id)->where('art_id', $art_id)->count() == 0) {
return $this->failed([], 'ارت مورد نظر یافت نشد', 404);
}
FolderArt::query()->where('folder_id', $id)->where('art_id', $art_id)->delete();
return $this->success([], 'حذف شد', 'ارت با موفقیت حذف شد');
}
}