diff --git a/app/Console/Commands/AddSubscriptionDays.php b/app/Console/Commands/AddSubscriptionDays.php index cd79588..5f92f67 100644 --- a/app/Console/Commands/AddSubscriptionDays.php +++ b/app/Console/Commands/AddSubscriptionDays.php @@ -31,37 +31,41 @@ class AddSubscriptionDays extends Command if ($days <= 0) { $this->error('Days must be a positive integer.'); + return self::FAILURE; } - if ($onlyWithoutSubscription && !$allUsers) { + if ($onlyWithoutSubscription && ! $allUsers) { $this->error('The --only-without-subscription option can only be used with --all-users.'); + return self::FAILURE; } if ($allUsers) { $planId = $this->option('plan-id'); - if (!$planId) { + if (! $planId) { $this->error('When using --all-users you must provide --plan-id for users without a subscription.'); + return self::FAILURE; } $plan = SubscribePlan::find($planId); - if (!$plan) { + if (! $plan) { $this->error('Subscribe plan not found for the given --plan-id.'); + return self::FAILURE; } } if ($allUsers) { if ($onlyWithoutSubscription) { - $this->info("Granting {$days} day(s) only to users without a subscription." . ($dryRun ? ' (dry-run)' : '')); + $this->info("Granting {$days} day(s) only to users without a subscription.".($dryRun ? ' (dry-run)' : '')); } else { - $this->info("Granting {$days} day(s) to every user." . ($dryRun ? ' (dry-run)' : '')); + $this->info("Granting {$days} day(s) to every user.".($dryRun ? ' (dry-run)' : '')); } } else { $scopeLabel = $includeExpired ? 'all' : 'active'; - $this->info("Extending {$scopeLabel} subscriptions by {$days} day(s)." . ($dryRun ? ' (dry-run)' : '')); + $this->info("Extending {$scopeLabel} subscriptions by {$days} day(s).".($dryRun ? ' (dry-run)' : '')); } $touched = 0; @@ -100,7 +104,7 @@ class AddSubscriptionDays extends Command }); } else { $query = UserSubscriber::query(); - if (!$includeExpired) { + if (! $includeExpired) { $query->where('expired_at', '>', now()); } diff --git a/app/Http/Controllers/Admin/ArtController.php b/app/Http/Controllers/Admin/ArtController.php index 6b170c7..3b62b0f 100644 --- a/app/Http/Controllers/Admin/ArtController.php +++ b/app/Http/Controllers/Admin/ArtController.php @@ -44,9 +44,9 @@ class ArtController extends Controller $laws = Law::all(); $sections = Section::all(); $divisions = Division::all(); - $branches = Branch::all(); + $branches = Branch::all(); - return view('admin.art.create', compact('chapters', 'parts', 'gates', 'books', 'volums', 'laws', 'sections','branches','divisions')); + return view('admin.art.create', compact('chapters', 'parts', 'gates', 'books', 'volums', 'laws', 'sections', 'branches', 'divisions')); } public function store(Request $request) @@ -64,7 +64,7 @@ class ArtController extends Controller 'law_id' => 'required', 'division_id' => 'nullable', 'branch_id' => 'nullable', - 'is_free' => 'nullable' + 'is_free' => 'nullable', ]); $validated['is_free'] = $request->input('is_free') ? true : false; @@ -84,10 +84,9 @@ class ArtController extends Controller $laws = Law::all(); $sections = Section::all(); $divisions = Division::all(); - $branches = Branch::all(); + $branches = Branch::all(); - - return view('admin.art.update', compact('art', 'chapters', 'parts', 'gates', 'books', 'volums', 'laws', 'sections','branches','divisions')); + return view('admin.art.update', compact('art', 'chapters', 'parts', 'gates', 'books', 'volums', 'laws', 'sections', 'branches', 'divisions')); } public function update(Request $request, Art $art) @@ -106,14 +105,14 @@ class ArtController extends Controller 'law_id' => 'required', 'division_id' => 'nullable', 'branch_id' => 'nullable', - 'is_free' => 'nullable' + 'is_free' => 'nullable', ]); $validated['is_free'] = $request->input('is_free') ? true : false; $art->update($validated); - return redirect(route('art.edit',$art->id)); + return redirect(route('art.edit', $art->id)); } public function destroy(Art $art) diff --git a/app/Http/Controllers/Admin/BookController.php b/app/Http/Controllers/Admin/BookController.php index 890042b..59fc810 100644 --- a/app/Http/Controllers/Admin/BookController.php +++ b/app/Http/Controllers/Admin/BookController.php @@ -15,7 +15,7 @@ class BookController extends Controller $query = Book::query(); if ($request->filled('q')) { - $query->where('title', 'like', '%' . $request->q . '%'); + $query->where('title', 'like', '%'.$request->q.'%'); } $perPage = min(max((int) $request->input('per_page', 15), 10), 100); diff --git a/app/Http/Controllers/Admin/BranchController.php b/app/Http/Controllers/Admin/BranchController.php index b49d7e9..6b2d2fd 100644 --- a/app/Http/Controllers/Admin/BranchController.php +++ b/app/Http/Controllers/Admin/BranchController.php @@ -21,7 +21,7 @@ class BranchController extends Controller $query = Branch::query(); if ($request->filled('q')) { - $query->where('title', 'like', '%' . $request->q . '%'); + $query->where('title', 'like', '%'.$request->q.'%'); } $perPage = min(max((int) $request->input('per_page', 15), 10), 100); @@ -41,7 +41,7 @@ class BranchController extends Controller $sections = Section::all(); $divisions = Division::all(); - return view('admin.branch.create', compact('chapters', 'parts', 'gates', 'books', 'volums', 'laws', 'sections','divisions')); + return view('admin.branch.create', compact('chapters', 'parts', 'gates', 'books', 'volums', 'laws', 'sections', 'divisions')); } public function store(Request $request) @@ -75,7 +75,7 @@ class BranchController extends Controller $sections = Section::all(); $divisions = Division::all(); - return view('admin.branch.update', compact('branch', 'chapters', 'parts', 'gates', 'books', 'volums', 'laws', 'sections','divisions')); + return view('admin.branch.update', compact('branch', 'chapters', 'parts', 'gates', 'books', 'volums', 'laws', 'sections', 'divisions')); } public function update(Request $request, Branch $branch) @@ -83,7 +83,7 @@ class BranchController extends Controller $validated = $request->validate([ 'title' => 'required', - 'number' => 'required', + 'number' => 'required', 'chapter_id' => 'nullable', 'part_id' => 'nullable', 'gate_id' => 'nullable', @@ -104,5 +104,5 @@ class BranchController extends Controller $branch->delete(); return redirect(route('branch.index')); - } + } } diff --git a/app/Http/Controllers/Admin/BylawCodificationLinkController.php b/app/Http/Controllers/Admin/BylawCodificationLinkController.php new file mode 100644 index 0000000..d336257 --- /dev/null +++ b/app/Http/Controllers/Admin/BylawCodificationLinkController.php @@ -0,0 +1,56 @@ +paginate(15); + + return view('admin.bylaw-codification-link.index', compact('items')); + } + + public function create() + { + return view('admin.bylaw-codification-link.create'); + } + + public function store(Request $request) + { + $data = $request->validate(['source_entity_type' => 'required|in:bylaw_node,bylaw_doc,law_doc,court_verdict,advisory_opinion', 'source_entity_id' => 'required|integer', 'target_entity_type' => 'required|in:bylaw_node,bylaw_doc,law_doc,court_verdict,advisory_opinion', 'target_entity_id' => 'required|integer', 'link_type' => 'required|in:repeals_explicitly,repeals_implicitly,annuls_entirely,annuls_partially,amends,adds_to,interprets,is_executive_bylaw_of', 'effective_date' => 'nullable|date', 'justification' => 'nullable|string']); + $data['created_at'] = now(); + BylawCodificationLink::create($data); + + return redirect(route('bylaw-codification-link.index')); + } + + public function edit(BylawCodificationLink $bylawCodificationLink) + { + return view('admin.bylaw-codification-link.update', compact('bylawCodificationLink')); + } + + public function show(BylawCodificationLink $bylawCodificationLink) + { + return redirect(route('bylaw-codification-link.edit', $bylawCodificationLink)); + } + + public function update(Request $request, BylawCodificationLink $bylawCodificationLink) + { + $data = $request->validate(['source_entity_type' => 'required|in:bylaw_node,bylaw_doc,law_doc,court_verdict,advisory_opinion', 'source_entity_id' => 'required|integer', 'target_entity_type' => 'required|in:bylaw_node,bylaw_doc,law_doc,court_verdict,advisory_opinion', 'target_entity_id' => 'required|integer', 'link_type' => 'required|in:repeals_explicitly,repeals_implicitly,annuls_entirely,annuls_partially,amends,adds_to,interprets,is_executive_bylaw_of', 'effective_date' => 'nullable|date', 'justification' => 'nullable|string']); + $bylawCodificationLink->update($data); + + return redirect(route('bylaw-codification-link.edit', $bylawCodificationLink)); + } + + public function destroy(BylawCodificationLink $bylawCodificationLink) + { + $bylawCodificationLink->delete(); + + return redirect(route('bylaw-codification-link.index')); + } +} diff --git a/app/Http/Controllers/Admin/BylawDocumentController.php b/app/Http/Controllers/Admin/BylawDocumentController.php new file mode 100644 index 0000000..080adf8 --- /dev/null +++ b/app/Http/Controllers/Admin/BylawDocumentController.php @@ -0,0 +1,69 @@ +filled('q')) { + $query->where('title', 'like', "%{$request->q}%"); + } + $items = $query->latest()->paginate(15)->withQueryString(); + + return view('admin.bylaw-document.index', compact('items')); + } + + public function create() + { + $categories = BylawSubjectCategory::all(); + $authorities = BylawLegalAuthority::all(); + + return view('admin.bylaw-document.create', compact('categories', 'authorities')); + } + + public function store(Request $request) + { + $data = $request->validate(['title' => 'required|string|max:1000', 'category_id' => 'nullable|exists:bylaw_subject_categories,id', 'approval_authority_id' => 'nullable|exists:bylaw_legal_authorities,id', 'approval_date' => 'nullable|date', 'promulgation_authority_id' => 'nullable|exists:bylaw_legal_authorities,id', 'promulgation_date' => 'nullable|date', 'promulgation_number' => 'nullable|string|max:100', 'official_gazette_number' => 'nullable|string|max:100', 'official_gazette_date' => 'nullable|date', 'execution_date' => 'nullable|date', 'bylaw_type' => 'required|in:executive,delegated,independent', 'global_status' => 'required|in:valid,explicitly_repealed,implicitly_repealed,annulled,expired,draft', 'pdf_file_path' => 'nullable|string|max:500', 'is_published' => 'nullable|boolean', 'description' => 'nullable|string']); + $data['is_published'] = $request->boolean('is_published'); + BylawDocument::create($data); + + return redirect(route('bylaw-document.index')); + } + + public function edit(BylawDocument $bylawDocument) + { + $categories = BylawSubjectCategory::all(); + $authorities = BylawLegalAuthority::all(); + + return view('admin.bylaw-document.update', compact('bylawDocument', 'categories', 'authorities')); + } + + public function show(BylawDocument $bylawDocument) + { + return redirect(route('bylaw-document.edit', $bylawDocument)); + } + + public function update(Request $request, BylawDocument $bylawDocument) + { + $data = $request->validate(['title' => 'required|string|max:1000', 'category_id' => 'nullable|exists:bylaw_subject_categories,id', 'approval_authority_id' => 'nullable|exists:bylaw_legal_authorities,id', 'approval_date' => 'nullable|date', 'promulgation_authority_id' => 'nullable|exists:bylaw_legal_authorities,id', 'promulgation_date' => 'nullable|date', 'promulgation_number' => 'nullable|string|max:100', 'official_gazette_number' => 'nullable|string|max:100', 'official_gazette_date' => 'nullable|date', 'execution_date' => 'nullable|date', 'bylaw_type' => 'required|in:executive,delegated,independent', 'global_status' => 'required|in:valid,explicitly_repealed,implicitly_repealed,annulled,expired,draft', 'pdf_file_path' => 'nullable|string|max:500', 'is_published' => 'nullable|boolean', 'description' => 'nullable|string']); + $data['is_published'] = $request->boolean('is_published'); + $bylawDocument->update($data); + + return redirect(route('bylaw-document.edit', $bylawDocument)); + } + + public function destroy(BylawDocument $bylawDocument) + { + $bylawDocument->delete(); + + return redirect(route('bylaw-document.index')); + } +} diff --git a/app/Http/Controllers/Admin/BylawLegalAuthorityController.php b/app/Http/Controllers/Admin/BylawLegalAuthorityController.php new file mode 100644 index 0000000..1dc0108 --- /dev/null +++ b/app/Http/Controllers/Admin/BylawLegalAuthorityController.php @@ -0,0 +1,59 @@ +filled('q')) { + $query->where('name', 'like', "%{$request->q}%"); + } + $items = $query->latest()->paginate(15)->withQueryString(); + + return view('admin.bylaw-legal-authority.index', compact('items')); + } + + public function create() + { + return view('admin.bylaw-legal-authority.create'); + } + + public function store(Request $request) + { + $data = $request->validate(['name' => 'required|unique:bylaw_legal_authorities,name', 'authority_type' => 'required|in:executive,judicial,legislative,administrative,other', 'description' => 'nullable|string']); + BylawLegalAuthority::create($data); + + return redirect(route('bylaw-legal-authority.index')); + } + + public function edit(BylawLegalAuthority $bylawLegalAuthority) + { + return view('admin.bylaw-legal-authority.update', compact('bylawLegalAuthority')); + } + + public function show(BylawLegalAuthority $bylawLegalAuthority) + { + return redirect(route('bylaw-legal-authority.edit', $bylawLegalAuthority)); + } + + public function update(Request $request, BylawLegalAuthority $bylawLegalAuthority) + { + $data = $request->validate(['name' => 'required|unique:bylaw_legal_authorities,name,'.$bylawLegalAuthority->id, 'authority_type' => 'required|in:executive,judicial,legislative,administrative,other', 'description' => 'nullable|string']); + $bylawLegalAuthority->update($data); + + return redirect(route('bylaw-legal-authority.edit', $bylawLegalAuthority)); + } + + public function destroy(BylawLegalAuthority $bylawLegalAuthority) + { + $bylawLegalAuthority->delete(); + + return redirect(route('bylaw-legal-authority.index')); + } +} diff --git a/app/Http/Controllers/Admin/BylawNodeController.php b/app/Http/Controllers/Admin/BylawNodeController.php new file mode 100644 index 0000000..5543d98 --- /dev/null +++ b/app/Http/Controllers/Admin/BylawNodeController.php @@ -0,0 +1,57 @@ +latest()->paginate(15); + + return view('admin.bylaw-node.index', compact('items')); + } + + public function create() + { + return view('admin.bylaw-node.create', ['documents' => BylawDocument::all(), 'types' => BylawNodeType::all(), 'parents' => BylawNode::all()]); + } + + public function store(Request $request) + { + $data = $request->validate(['document_id' => 'required|exists:bylaw_documents,id', 'parent_id' => 'nullable|exists:bylaw_nodes,id', 'node_type_id' => 'required|exists:bylaw_node_types,id', 'node_identifier' => 'nullable|string|max:50', 'title' => 'nullable|string|max:500', 'node_content' => 'nullable|string', 'sort_order' => 'nullable|integer', 'valid_from' => 'nullable|date', 'valid_to' => 'nullable|date', 'node_status' => 'required|in:valid,repealed,annulled,amended,suspended']); + BylawNode::create($data); + + return redirect(route('bylaw-node.index')); + } + + public function edit(BylawNode $bylawNode) + { + return view('admin.bylaw-node.update', ['bylawNode' => $bylawNode, 'documents' => BylawDocument::all(), 'types' => BylawNodeType::all(), 'parents' => BylawNode::where('id', '!=', $bylawNode->id)->get()]); + } + + public function show(BylawNode $bylawNode) + { + return redirect(route('bylaw-node.edit', $bylawNode)); + } + + public function update(Request $request, BylawNode $bylawNode) + { + $data = $request->validate(['document_id' => 'required|exists:bylaw_documents,id', 'parent_id' => 'nullable|exists:bylaw_nodes,id', 'node_type_id' => 'required|exists:bylaw_node_types,id', 'node_identifier' => 'nullable|string|max:50', 'title' => 'nullable|string|max:500', 'node_content' => 'nullable|string', 'sort_order' => 'nullable|integer', 'valid_from' => 'nullable|date', 'valid_to' => 'nullable|date', 'node_status' => 'required|in:valid,repealed,annulled,amended,suspended']); + $bylawNode->update($data); + + return redirect(route('bylaw-node.edit', $bylawNode)); + } + + public function destroy(BylawNode $bylawNode) + { + $bylawNode->delete(); + + return redirect(route('bylaw-node.index')); + } +} diff --git a/app/Http/Controllers/Admin/BylawNodeTypeController.php b/app/Http/Controllers/Admin/BylawNodeTypeController.php new file mode 100644 index 0000000..52c7a08 --- /dev/null +++ b/app/Http/Controllers/Admin/BylawNodeTypeController.php @@ -0,0 +1,55 @@ +paginate(15)->withQueryString(); + + return view('admin.bylaw-node-type.index', compact('items')); + } + + public function create() + { + return view('admin.bylaw-node-type.create'); + } + + public function store(Request $request) + { + $data = $request->validate(['name' => 'required|unique:bylaw_node_types,name', 'hierarchy_level' => 'required|integer']); + BylawNodeType::create($data); + + return redirect(route('bylaw-node-type.index')); + } + + public function edit(BylawNodeType $bylawNodeType) + { + return view('admin.bylaw-node-type.update', compact('bylawNodeType')); + } + + public function show(BylawNodeType $bylawNodeType) + { + return redirect(route('bylaw-node-type.edit', $bylawNodeType)); + } + + public function update(Request $request, BylawNodeType $bylawNodeType) + { + $data = $request->validate(['name' => 'required|unique:bylaw_node_types,name,'.$bylawNodeType->id, 'hierarchy_level' => 'required|integer']); + $bylawNodeType->update($data); + + return redirect(route('bylaw-node-type.edit', $bylawNodeType)); + } + + public function destroy(BylawNodeType $bylawNodeType) + { + $bylawNodeType->delete(); + + return redirect(route('bylaw-node-type.index')); + } +} diff --git a/app/Http/Controllers/Admin/BylawSubjectCategoryController.php b/app/Http/Controllers/Admin/BylawSubjectCategoryController.php new file mode 100644 index 0000000..e99a171 --- /dev/null +++ b/app/Http/Controllers/Admin/BylawSubjectCategoryController.php @@ -0,0 +1,64 @@ +filled('q')) { + $query->where('name', 'like', "%{$request->q}%"); + } $items = $query->latest()->paginate(15)->withQueryString(); + + return view('admin.bylaw-subject-category.index', compact('items')); + } + + public function create() + { + $parents = BylawSubjectCategory::all(); + + return view('admin.bylaw-subject-category.create', compact('parents')); + } + + public function store(Request $request) + { + $data = $request->validate(['parent_id' => 'nullable|exists:bylaw_subject_categories,id', 'name' => 'required|string', 'slug' => 'nullable|string|unique:bylaw_subject_categories,slug', 'sort_order' => 'nullable|integer']); + $data['slug'] = $data['slug'] ?? Str::slug($data['name']); + BylawSubjectCategory::create($data); + + return redirect(route('bylaw-subject-category.index')); + } + + public function edit(BylawSubjectCategory $bylawSubjectCategory) + { + $parents = BylawSubjectCategory::where('id', '!=', $bylawSubjectCategory->id)->get(); + + return view('admin.bylaw-subject-category.update', compact('bylawSubjectCategory', 'parents')); + } + + public function show(BylawSubjectCategory $bylawSubjectCategory) + { + return redirect(route('bylaw-subject-category.edit', $bylawSubjectCategory)); + } + + public function update(Request $request, BylawSubjectCategory $bylawSubjectCategory) + { + $data = $request->validate(['parent_id' => 'nullable|exists:bylaw_subject_categories,id', 'name' => 'required|string', 'slug' => 'required|string|unique:bylaw_subject_categories,slug,'.$bylawSubjectCategory->id, 'sort_order' => 'nullable|integer']); + $bylawSubjectCategory->update($data); + + return redirect(route('bylaw-subject-category.edit', $bylawSubjectCategory)); + } + + public function destroy(BylawSubjectCategory $bylawSubjectCategory) + { + $bylawSubjectCategory->delete(); + + return redirect(route('bylaw-subject-category.index')); + } +} diff --git a/app/Http/Controllers/Admin/CategoryController.php b/app/Http/Controllers/Admin/CategoryController.php index 28c57ad..9e7e6a4 100644 --- a/app/Http/Controllers/Admin/CategoryController.php +++ b/app/Http/Controllers/Admin/CategoryController.php @@ -13,7 +13,7 @@ class CategoryController extends Controller $query = Category::query(); if ($request->filled('q')) { - $query->where('name', 'like', '%' . $request->q . '%'); + $query->where('name', 'like', '%'.$request->q.'%'); } if ($request->filled('type')) { $query->where('type', $request->type); @@ -32,12 +32,11 @@ class CategoryController extends Controller public function store(Request $request) { - $validated = $request->validate([ + $validated = $request->validate([ 'name' => 'required', - 'type' => 'required' + 'type' => 'required', ]); - Category::create($validated); return redirect(route('categories.index')); @@ -45,25 +44,25 @@ class CategoryController extends Controller public function edit(Category $category) { - return view('admin.categories.update',compact('category')); + return view('admin.categories.update', compact('category')); } public function update(Request $request, Category $category) { - $validated = $request->validate([ + $validated = $request->validate([ 'name' => 'required', - 'type' => 'required' + 'type' => 'required', ]); $category->update($validated); - + return redirect(route('categories.index')); } public function destroy(Category $category) { $category->delete(); - + return redirect(route('categories.index')); } } diff --git a/app/Http/Controllers/Admin/ChapterController.php b/app/Http/Controllers/Admin/ChapterController.php index 0007ef1..32f4c2c 100644 --- a/app/Http/Controllers/Admin/ChapterController.php +++ b/app/Http/Controllers/Admin/ChapterController.php @@ -18,7 +18,7 @@ class ChapterController extends Controller $query = Chapter::query(); if ($request->filled('q')) { - $query->where('title', 'like', '%' . $request->q . '%'); + $query->where('title', 'like', '%'.$request->q.'%'); } $perPage = min(max((int) $request->input('per_page', 15), 10), 100); @@ -35,7 +35,7 @@ class ChapterController extends Controller $sections = Section::all(); $divisions = Division::all(); - return view('admin.chapter.create', compact('sections', 'books', 'volums', 'laws','divisions')); + return view('admin.chapter.create', compact('sections', 'books', 'volums', 'laws', 'divisions')); } public function store(Request $request) @@ -47,7 +47,7 @@ class ChapterController extends Controller 'book_id' => 'nullable', 'volum_id' => 'nullable', 'law_id' => 'nullable', - 'division_id' => 'nullable' + 'division_id' => 'nullable', ]); Chapter::query()->create($validated); @@ -63,7 +63,7 @@ class ChapterController extends Controller $laws = Law::all(); $divisions = Division::all(); - return view('admin.chapter.update', compact('sections', 'chapter', 'books', 'volums', 'laws','divisions')); + return view('admin.chapter.update', compact('sections', 'chapter', 'books', 'volums', 'laws', 'divisions')); } public function update(Request $request, Chapter $chapter) @@ -75,7 +75,7 @@ class ChapterController extends Controller 'book_id' => 'nullable', 'volum_id' => 'nullable', 'law_id' => 'nullable', - 'division_id' => 'nullable' + 'division_id' => 'nullable', ]); $chapter->update($validated); diff --git a/app/Http/Controllers/Admin/DivisionController.php b/app/Http/Controllers/Admin/DivisionController.php index 86327c7..d6fca43 100644 --- a/app/Http/Controllers/Admin/DivisionController.php +++ b/app/Http/Controllers/Admin/DivisionController.php @@ -16,7 +16,7 @@ class DivisionController extends Controller $query = Division::query(); if ($request->filled('q')) { - $query->where('title', 'like', '%' . $request->q . '%'); + $query->where('title', 'like', '%'.$request->q.'%'); } $perPage = min(max((int) $request->input('per_page', 15), 10), 100); @@ -55,7 +55,7 @@ class DivisionController extends Controller $volums = Volum::all(); $laws = Law::all(); - return view('admin.division.update', compact('division','books', 'volums', 'laws')); + return view('admin.division.update', compact('division', 'books', 'volums', 'laws')); } public function update(Request $request, Division $division) diff --git a/app/Http/Controllers/Admin/GateController.php b/app/Http/Controllers/Admin/GateController.php index 6018910..fd18ebf 100644 --- a/app/Http/Controllers/Admin/GateController.php +++ b/app/Http/Controllers/Admin/GateController.php @@ -20,7 +20,7 @@ class GateController extends Controller $query = Gate::query(); if ($request->filled('q')) { - $query->where('title', 'like', '%' . $request->q . '%'); + $query->where('title', 'like', '%'.$request->q.'%'); } $perPage = min(max((int) $request->input('per_page', 15), 10), 100); @@ -37,9 +37,9 @@ class GateController extends Controller $books = Book::all(); $volums = Volum::all(); $laws = Law::all(); - $divisions = Division::all(); + $divisions = Division::all(); - return view('admin.gate.create', compact('parts', 'chapters', 'sections', 'books', 'volums', 'laws','divisions')); + return view('admin.gate.create', compact('parts', 'chapters', 'sections', 'books', 'volums', 'laws', 'divisions')); } public function store(Request $request) @@ -64,9 +64,9 @@ class GateController extends Controller $books = Book::all(); $volums = Volum::all(); $laws = Law::all(); - $divisions = Division::all(); + $divisions = Division::all(); - return view('admin.gate.update', compact('gate', 'parts', 'chapters', 'sections', 'books', 'volums', 'laws','divisions')); + return view('admin.gate.update', compact('gate', 'parts', 'chapters', 'sections', 'books', 'volums', 'laws', 'divisions')); } public function update(Request $request, Gate $gate) diff --git a/app/Http/Controllers/Admin/JudicialPrecedentCategoryController.php b/app/Http/Controllers/Admin/JudicialPrecedentCategoryController.php index 97f3b01..9f2fc99 100644 --- a/app/Http/Controllers/Admin/JudicialPrecedentCategoryController.php +++ b/app/Http/Controllers/Admin/JudicialPrecedentCategoryController.php @@ -40,7 +40,7 @@ class JudicialPrecedentCategoryController extends Controller public function store(Request $request) { $validated = $request->validate([ - 'name' => 'required|string|unique:judicial_precedent_categories,name' + 'name' => 'required|string|unique:judicial_precedent_categories,name', ]); JudicialPrecedentCategory::create($validated); @@ -70,7 +70,7 @@ class JudicialPrecedentCategoryController extends Controller public function update(Request $request, JudicialPrecedentCategory $judicialPrecedentCategory) { $validated = $request->validate([ - 'name' => 'required|string|unique:judicial_precedent_categories,name,' . $judicialPrecedentCategory->id + 'name' => 'required|string|unique:judicial_precedent_categories,name,'.$judicialPrecedentCategory->id, ]); $judicialPrecedentCategory->update($validated); @@ -84,6 +84,7 @@ class JudicialPrecedentCategoryController extends Controller public function destroy(JudicialPrecedentCategory $judicialPrecedentCategory) { $judicialPrecedentCategory->delete(); + return redirect(route('judicial-precedent-category.index')); } } diff --git a/app/Http/Controllers/Admin/JudicialPrecedentController.php b/app/Http/Controllers/Admin/JudicialPrecedentController.php index 902ec18..bf01c82 100644 --- a/app/Http/Controllers/Admin/JudicialPrecedentController.php +++ b/app/Http/Controllers/Admin/JudicialPrecedentController.php @@ -33,6 +33,7 @@ class JudicialPrecedentController extends Controller { $arts = Art::all(); $categories = JudicialPrecedentCategory::all(); + return view('admin.judicial-precedent.create', compact('arts', 'categories')); } @@ -46,7 +47,7 @@ class JudicialPrecedentController extends Controller 'issuing_authority' => 'nullable|string', 'category_id' => 'nullable|exists:judicial_precedent_categories,id', 'art_ids' => 'nullable|array', - 'art_ids.*' => 'exists:arts,id' + 'art_ids.*' => 'exists:arts,id', ]); $judicialPrecedent = JudicialPrecedent::create([ @@ -55,10 +56,10 @@ class JudicialPrecedentController extends Controller 'subject' => $validated['subject'], 'full_text' => $validated['full_text'], 'issuing_authority' => $validated['issuing_authority'] ?? 'هیأت عمومی دیوان عالی کشور', - 'category_id' => $validated['category_id'] + 'category_id' => $validated['category_id'], ]); - if (!empty($validated['art_ids'])) { + if (! empty($validated['art_ids'])) { $judicialPrecedent->arts()->attach($validated['art_ids']); } @@ -70,25 +71,25 @@ class JudicialPrecedentController extends Controller $arts = Art::all(); $categories = JudicialPrecedentCategory::all(); $selectedArtIds = $judicialPrecedent->arts->pluck('id')->toArray(); - + return view('admin.judicial-precedent.update', compact('judicialPrecedent', 'arts', 'categories', 'selectedArtIds')); } public function update(Request $request, JudicialPrecedent $judicialPrecedent) { $validated = $request->validate([ - 'ruling_number' => 'required|unique:judicial_precedents,ruling_number,' . $judicialPrecedent->id, + 'ruling_number' => 'required|unique:judicial_precedents,ruling_number,'.$judicialPrecedent->id, 'ruling_date' => 'required|date', 'subject' => 'required|string', 'full_text' => 'required|string', 'issuing_authority' => 'nullable|string', 'category_id' => 'nullable|exists:judicial_precedent_categories,id', 'art_ids' => 'nullable|array', - 'art_ids.*' => 'exists:arts,id' + 'art_ids.*' => 'exists:arts,id', ]); $judicialPrecedent->update($validated); - + $judicialPrecedent->arts()->sync($validated['art_ids'] ?? []); return redirect(route('judicial-precedent.edit', $judicialPrecedent->id)); @@ -97,6 +98,7 @@ class JudicialPrecedentController extends Controller public function destroy(JudicialPrecedent $judicialPrecedent) { $judicialPrecedent->delete(); + return redirect(route('judicial-precedent.index')); } } diff --git a/app/Http/Controllers/Admin/LawController.php b/app/Http/Controllers/Admin/LawController.php index d086c5c..33a9e2c 100644 --- a/app/Http/Controllers/Admin/LawController.php +++ b/app/Http/Controllers/Admin/LawController.php @@ -14,7 +14,7 @@ class LawController extends Controller $query = Law::query(); if ($request->filled('q')) { - $query->where('title', 'like', '%' . $request->q . '%'); + $query->where('title', 'like', '%'.$request->q.'%'); } if ($request->filled('locked')) { $query->where('is_locked', $request->locked === '1'); @@ -46,7 +46,7 @@ class LawController extends Controller $validated['is_locked'] = $request->has('is_locked', false); if ($request->hasFile('image') && $request->file('image')->isValid()) { - $imageName = uniqid('image_', true) . '.' . $request->file('image')->getClientOriginalExtension(); + $imageName = uniqid('image_', true).'.'.$request->file('image')->getClientOriginalExtension(); $request->file('image')->move(public_path('images'), $imageName); @@ -58,11 +58,10 @@ class LawController extends Controller return redirect()->route('law.index')->with('success', 'Law created successfully.'); } - - public function edit(Law $law) { $categories = Category::all(); + return view('admin.law.update', compact('law', 'categories')); } @@ -79,7 +78,7 @@ class LawController extends Controller $validated['is_locked'] = $request->boolean('is_locked'); if ($request->hasFile('image') && $request->file('image')->isValid()) { - $imageName = uniqid('image_', true) . '.' . $request->file('image')->getClientOriginalExtension(); + $imageName = uniqid('image_', true).'.'.$request->file('image')->getClientOriginalExtension(); $request->file('image')->move(public_path('images'), $imageName); $validated['image'] = $imageName; } diff --git a/app/Http/Controllers/Admin/LegalOpinionCategoryController.php b/app/Http/Controllers/Admin/LegalOpinionCategoryController.php index b0941f1..f4cb2a3 100644 --- a/app/Http/Controllers/Admin/LegalOpinionCategoryController.php +++ b/app/Http/Controllers/Admin/LegalOpinionCategoryController.php @@ -52,7 +52,7 @@ class LegalOpinionCategoryController extends Controller public function update(Request $request, LegalOpinionCategory $legalOpinionCategory) { $validated = $request->validate([ - 'name' => 'required|string|unique:legal_opinion_categories,name,' . $legalOpinionCategory->id, + 'name' => 'required|string|unique:legal_opinion_categories,name,'.$legalOpinionCategory->id, ]); $legalOpinionCategory->update($validated); diff --git a/app/Http/Controllers/Admin/LegalOpinionController.php b/app/Http/Controllers/Admin/LegalOpinionController.php index efa9b46..d339c87 100644 --- a/app/Http/Controllers/Admin/LegalOpinionController.php +++ b/app/Http/Controllers/Admin/LegalOpinionController.php @@ -64,7 +64,7 @@ class LegalOpinionController extends Controller 'category_id' => $validated['category_id'], ]); - if (!empty($validated['art_ids'])) { + if (! empty($validated['art_ids'])) { $legalOpinion->arts()->attach($validated['art_ids']); } diff --git a/app/Http/Controllers/Admin/NotificationController.php b/app/Http/Controllers/Admin/NotificationController.php index fa7a84f..ffabe3f 100644 --- a/app/Http/Controllers/Admin/NotificationController.php +++ b/app/Http/Controllers/Admin/NotificationController.php @@ -36,6 +36,7 @@ class NotificationController extends Controller public function store(StoreRequest $request) { Notification::create($request->validated()); + return redirect()->route('notifications.index'); } @@ -47,12 +48,14 @@ class NotificationController extends Controller public function update(UpdateRequest $request, Notification $notification) { $notification->update($request->validated()); + return redirect()->route('notifications.index'); } public function destroy(Notification $notification) { $notification->delete(); + return redirect()->route('notifications.index'); } } diff --git a/app/Http/Controllers/Admin/PartController.php b/app/Http/Controllers/Admin/PartController.php index e215aa8..9dbdd0e 100644 --- a/app/Http/Controllers/Admin/PartController.php +++ b/app/Http/Controllers/Admin/PartController.php @@ -19,7 +19,7 @@ class PartController extends Controller $query = Part::query(); if ($request->filled('q')) { - $query->where('title', 'like', '%' . $request->q . '%'); + $query->where('title', 'like', '%'.$request->q.'%'); } $perPage = min(max((int) $request->input('per_page', 15), 10), 100); @@ -37,7 +37,7 @@ class PartController extends Controller $laws = Law::all(); $divisions = Division::all(); - return view('admin.part.create', compact('chapters', 'sections', 'books', 'volums', 'laws','divisions')); + return view('admin.part.create', compact('chapters', 'sections', 'books', 'volums', 'laws', 'divisions')); } public function store(Request $request) @@ -50,7 +50,7 @@ class PartController extends Controller 'book_id' => 'nullable', 'volum_id' => 'nullable', 'law_id' => 'nullable', - 'division_id' => 'nullable' + 'division_id' => 'nullable', ]); Part::query()->create($validated); @@ -67,7 +67,7 @@ class PartController extends Controller $laws = Law::all(); $divisions = Division::all(); - return view('admin.part.update', compact('part', 'chapters', 'sections', 'books', 'volums', 'laws','divisions')); + return view('admin.part.update', compact('part', 'chapters', 'sections', 'books', 'volums', 'laws', 'divisions')); } public function update(Request $request, Part $part) @@ -80,7 +80,7 @@ class PartController extends Controller 'book_id' => 'nullable', 'volum_id' => 'nullable', 'law_id' => 'nullable', - 'division_id' => 'nullable' + 'division_id' => 'nullable', ]); $part->update($validated); diff --git a/app/Http/Controllers/Admin/SectionController.php b/app/Http/Controllers/Admin/SectionController.php index 1a57f2d..bcc74a1 100644 --- a/app/Http/Controllers/Admin/SectionController.php +++ b/app/Http/Controllers/Admin/SectionController.php @@ -17,7 +17,7 @@ class SectionController extends Controller $query = Section::query(); if ($request->filled('q')) { - $query->where('title', 'like', '%' . $request->q . '%'); + $query->where('title', 'like', '%'.$request->q.'%'); } $perPage = min(max((int) $request->input('per_page', 15), 10), 100); @@ -34,7 +34,7 @@ class SectionController extends Controller $sections = Section::all(); $divisions = Division::all(); - return view('admin.section.create', compact('books', 'volums', 'laws','sections','divisions')); + return view('admin.section.create', compact('books', 'volums', 'laws', 'sections', 'divisions')); } public function store(Request $request) @@ -45,7 +45,7 @@ class SectionController extends Controller 'book_id' => 'nullable', 'volum_id' => 'nullable', 'law_id' => 'nullable', - 'division_id' => 'nullable' + 'division_id' => 'nullable', ]); section::query()->create($validated); @@ -60,8 +60,8 @@ class SectionController extends Controller $laws = Law::all(); $sections = Section::all(); $divisions = Division::all(); - - return view('admin.section.update', compact('section', 'books', 'volums', 'laws','sections','divisions')); + + return view('admin.section.update', compact('section', 'books', 'volums', 'laws', 'sections', 'divisions')); } public function update(Request $request, Section $section) @@ -72,7 +72,7 @@ class SectionController extends Controller 'book_id' => 'nullable', 'volum_id' => 'nullable', 'law_id' => 'nullable', - 'division_id' => 'nullable' + 'division_id' => 'nullable', ]); $section->update($validated); diff --git a/app/Http/Controllers/Admin/SubscribePlanController.php b/app/Http/Controllers/Admin/SubscribePlanController.php index 5a2cf07..9c6a348 100644 --- a/app/Http/Controllers/Admin/SubscribePlanController.php +++ b/app/Http/Controllers/Admin/SubscribePlanController.php @@ -37,15 +37,15 @@ class SubscribePlanController extends Controller $validated['is_free'] = $request->has('is_free'); SubscribePlan::create($validated); - return redirect()->route('subscribe-plans.index'); - } + return redirect()->route('subscribe-plans.index'); + } public function edit(SubscribePlan $subscribePlan) { return view('admin.subscribe-plans.update', compact('subscribePlan')); } - + public function update(UpdateRequest $request, SubscribePlan $subscribePlan) { $validated = $request->validated(); @@ -53,12 +53,14 @@ class SubscribePlanController extends Controller $validated['is_free'] = $request->has('is_free'); $subscribePlan->update($validated); - return redirect()->route('subscribe-plans.index'); + + return redirect()->route('subscribe-plans.index'); } public function destroy(SubscribePlan $subscribePlan) { $subscribePlan->delete(); + return redirect()->route('subscribe-plans.index'); } } diff --git a/app/Http/Controllers/Admin/VersionController.php b/app/Http/Controllers/Admin/VersionController.php index 155f047..328fd9b 100644 --- a/app/Http/Controllers/Admin/VersionController.php +++ b/app/Http/Controllers/Admin/VersionController.php @@ -41,6 +41,7 @@ class VersionController extends Controller $validated['force_update'] = $validated['force_update'] == 'on' ? 1 : 0; } Version::create($validated); + return redirect(route('versions.index')); } @@ -56,12 +57,14 @@ class VersionController extends Controller $validated['force_update'] = $validated['force_update'] == 'on' ? 1 : 0; } $version->update($validated); + return redirect(route('versions.index')); } public function destroy(Version $version) { $version->delete(); + return redirect(route('versions.index')); } } diff --git a/app/Http/Controllers/Admin/VolumController.php b/app/Http/Controllers/Admin/VolumController.php index f1f4731..dba0da3 100644 --- a/app/Http/Controllers/Admin/VolumController.php +++ b/app/Http/Controllers/Admin/VolumController.php @@ -14,7 +14,7 @@ class VolumController extends Controller $query = Volum::query(); if ($request->filled('q')) { - $query->where('title', 'like', '%' . $request->q . '%'); + $query->where('title', 'like', '%'.$request->q.'%'); } $perPage = min(max((int) $request->input('per_page', 15), 10), 100); diff --git a/app/Http/Controllers/SuggestionController.php b/app/Http/Controllers/SuggestionController.php index 3638dbe..439de56 100644 --- a/app/Http/Controllers/SuggestionController.php +++ b/app/Http/Controllers/SuggestionController.php @@ -10,13 +10,13 @@ class SuggestionController extends Controller { use BaseApiResponse; - public function index(SuggestionRequest $requst) + public function index(SuggestionRequest $requst) { Suggestion::create([ 'user_id' => auth()->user()->id, - 'text' => $requst->text + 'text' => $requst->text, ]); - return $this->success(null,'موفقیت','پیشنهاد شما با موفقیت برای مدیر ارسال شد'); + return $this->success(null, 'موفقیت', 'پیشنهاد شما با موفقیت برای مدیر ارسال شد'); } } diff --git a/app/Http/Controllers/api/ArtController.php b/app/Http/Controllers/api/ArtController.php index 8bf7a88..6615d91 100644 --- a/app/Http/Controllers/api/ArtController.php +++ b/app/Http/Controllers/api/ArtController.php @@ -85,7 +85,7 @@ class ArtController extends Controller { $art = Art::select('id', 'title', 'number', 'text', 'law_id')->find($id); - if (!$art) { + if (! $art) { return $this->failed([], 'Art not found'); } @@ -96,12 +96,12 @@ class ArtController extends Controller } $art->is_like = $this->isLiked($art->id); - $art->note = Note::select('id', 'note', 'color_code','created_at')->where('user_id', auth()->user()->id)->where('art_id', $id)->get(); + $art->note = Note::select('id', 'note', 'color_code', 'created_at')->where('user_id', auth()->user()->id)->where('art_id', $id)->get(); $art->category = $law?->category?->name; $art->route = array_values($this->route(Art::class, $art)); $previousArt = Art::select('id', 'title', 'number', 'text', 'law_id') - ->where('law_id',$art->law_id) + ->where('law_id', $art->law_id) ->where('number', '<', $art->number) ->orderBy('number', 'desc') ->first(); @@ -115,7 +115,7 @@ class ArtController extends Controller } $nextArt = Art::select('id', 'title', 'number', 'text', 'law_id') - ->where('law_id',$art->law_id) + ->where('law_id', $art->law_id) ->where('number', '>', $art->number) ->orderBy('number') ->first(); @@ -155,7 +155,6 @@ class ArtController extends Controller return $this->success(null, 'Success', 'Art liked successfully'); } - private function isLiked($art_id): bool { return LikeArt::query()->where('art_id', $art_id) @@ -165,7 +164,7 @@ class ArtController extends Controller private function isLockedForCurrentUser(?Law $law): bool { - return !auth()->user()->isSubscriber() && (bool) $law?->is_locked; + return ! auth()->user()->isSubscriber() && (bool) $law?->is_locked; } public function likes() @@ -179,14 +178,13 @@ class ArtController extends Controller return [ 'id' => $q->art->id, 'title' => $q->art->title, - 'text' => $isLocked ? null : $q->art->text + 'text' => $isLocked ? null : $q->art->text, ]; }); return $this->success($likes); } - public function search(Request $request) { $validated = $request->validate([ @@ -201,7 +199,7 @@ class ArtController extends Controller 'branch_id' => 'nullable|array', 'category_id' => 'nullable|int', 'per_page' => 'nullable|integer', - 'search' => 'nullable|string' + 'search' => 'nullable|string', ]); $models = [ @@ -214,7 +212,7 @@ class ArtController extends Controller Part::class, Gate::class, Branch::class, - Art::class + Art::class, ]; $results = []; @@ -238,13 +236,13 @@ class ArtController extends Controller 'part_id', 'gate_id', 'chapter_id', - 'branch_id' + 'branch_id', ]; $model = new $modelClass; if ($model->getTable() == 'art') { $query->where(function ($query) use ($validated, $filters) { - if (!empty($validated['search'])) { + if (! empty($validated['search'])) { $query->where(function ($q) use ($validated) { $q->where('title', 'LIKE', "%{$validated['search']}%") ->orWhere('text', 'LIKE', "%{$validated['search']}%"); @@ -252,14 +250,13 @@ class ArtController extends Controller } foreach ($filters as $filter) { - if (!empty($validated[$filter])) { + if (! empty($validated[$filter])) { $query->whereIn($filter, $validated[$filter]); } } }); - - if (!empty($validated['category_id'])) { + if (! empty($validated['category_id'])) { $query->whereIn('law_id', Category::where('type', $this->convertValueTo($validated['category_id']))->get()->pluck('id')); } @@ -268,8 +265,8 @@ class ArtController extends Controller return $items->map(function ($item) use ($validated, $modelClass) { $text = $item->text ?? ''; $search = preg_quote($validated['search'] ?? '', '/'); - if (!empty($text) && preg_match('/\b(.{0,50})\b(' . $search . ')\b(.{0,50})\b/i', $text, $matches)) { - $context = trim($matches[1] ?? '') . ' ' . $matches[2] . ' ' . trim($matches[3] ?? ''); + if (! empty($text) && preg_match('/\b(.{0,50})\b('.$search.')\b(.{0,50})\b/i', $text, $matches)) { + $context = trim($matches[1] ?? '').' '.$matches[2].' '.trim($matches[3] ?? ''); } else { $context = $text; } @@ -289,11 +286,11 @@ class ArtController extends Controller 'count_art' => $law->arts->count(), 'count_volums' => $law->volums->count(), 'price' => $law->price, - 'image' => $law->image + 'image' => $law->image, ]; })->toArray(); } else { - $query = $query->where('title', 'LIKE', '%' . ($validated['search'] ?? '') . '%'); + $query = $query->where('title', 'LIKE', '%'.($validated['search'] ?? '').'%'); } $items = $query->paginate($validated['per_page'] ?? 10); @@ -306,21 +303,21 @@ class ArtController extends Controller 'title' => $item->title, 'number' => $item->number, 'type' => (new $modelClass)->getTable(), - 'is_locked' => auth()->user()->isSubscriber() !== false ? false : optional($law)->is_locked, + 'is_locked' => auth()->user()->isSubscriber() !== false ? false : optional($law)->is_locked, 'route' => array_values($this->route($modelClass, $item)), 'category' => optional($law?->category)?->name ?? '', - 'image' => $law->image + 'image' => $law->image, ]; - } else if ((new $modelClass)->getTable() == 'art') { + } elseif ((new $modelClass)->getTable() == 'art') { return [ 'id' => $item->id, 'title' => $item->title, 'number' => $item->number, 'type' => (new $modelClass)->getTable(), - 'is_locked' => auth()->user()->isSubscriber() !== false ? false : optional($law)->is_locked, + 'is_locked' => auth()->user()->isSubscriber() !== false ? false : optional($law)->is_locked, 'route' => array_values($this->route($modelClass, $item)), 'law' => $law?->title ?? '', - 'image' => $law->image + 'image' => $law->image, ]; } else { return [ @@ -328,7 +325,7 @@ class ArtController extends Controller 'title' => $item->title, 'number' => $item->number, 'type' => (new $modelClass)->getTable(), - 'is_locked' => auth()->user()->isSubscriber() !== false ? false : optional($law)->is_locked, + 'is_locked' => auth()->user()->isSubscriber() !== false ? false : optional($law)->is_locked, 'route' => array_values($this->route($modelClass, $item)), 'law' => $law?->title ?? '', ]; @@ -336,8 +333,6 @@ class ArtController extends Controller })->toArray(); } - - private function route($modelClass, $query) { if ((new $modelClass)->getTable() == 'art') { @@ -350,12 +345,14 @@ class ArtController extends Controller Chapter::find($query->chapter_id)?->title, Part::find($query->part_id)?->title, Gate::find($query->gate_id)?->title, - Branch::find($query->branch_id)?->title + Branch::find($query->branch_id)?->title, ]); $route = array_values($route); + return $route; } + return []; } @@ -365,7 +362,7 @@ class ArtController extends Controller $models = [ Law::class, - Art::class + Art::class, ]; $results = []; @@ -374,7 +371,6 @@ class ArtController extends Controller $results = array_merge($results, $this->searchModelFastSearch($modelClass, $search)); } - $models_other = [ Volum::class, Book::class, @@ -388,13 +384,12 @@ class ArtController extends Controller $found = false; foreach ($models_other as $modelClass) { - if (count($this->searchModelFastSearch($modelClass, $search)) > 0 && !$found) { + if (count($this->searchModelFastSearch($modelClass, $search)) > 0 && ! $found) { $results = array_merge($results, $this->searchModelFastSearch($modelClass, $search)); $found = true; } } - $models = [ Law::class, Volum::class, @@ -405,7 +400,7 @@ class ArtController extends Controller Part::class, Gate::class, Branch::class, - Art::class + Art::class, ]; $count_all = 0; @@ -414,7 +409,6 @@ class ArtController extends Controller $count_all += count($this->searchModel($modelClass, $search)); } - return $this->success(['items' => $results, 'count' => $count_all]); } @@ -449,7 +443,7 @@ class ArtController extends Controller 'title' => $q->title, 'type' => $table === 'section' ? 'sections' : $table, 'category' => $category, - 'law' => Law::where('id', $q->law_id)->first()?->title + 'law' => Law::where('id', $q->law_id)->first()?->title, ]; } @@ -458,7 +452,7 @@ class ArtController extends Controller 'title' => $q->title, 'type' => $table === 'section' ? 'sections' : $table, 'category' => $category, - 'image' => Law::where('id', $q->id)->first()?->image + 'image' => Law::where('id', $q->id)->first()?->image, ]; } @@ -474,13 +468,13 @@ class ArtController extends Controller Chapter::find($q->chapter_id)?->title, Part::find($q->part_id)?->title, Gate::find($q->gate_id)?->title, - Branch::find($q->branch_id)?->title + Branch::find($q->branch_id)?->title, ]); $text = $q->text; $search = preg_quote($search, '/'); - if (preg_match('/\b(.{0,50})\b(' . $search . ')\b(.{0,50})\b/i', $text, $matches)) { - $context = trim($matches[1]) . ' ' . $matches[2] . ' ' . trim($matches[3]); + if (preg_match('/\b(.{0,50})\b('.$search.')\b(.{0,50})\b/i', $text, $matches)) { + $context = trim($matches[1]).' '.$matches[2].' '.trim($matches[3]); } else { $context = $text; } @@ -499,7 +493,7 @@ class ArtController extends Controller 'count_art' => $law->arts->count(), 'count_volum' => $law->volums->count(), 'price' => $law->price, - 'image' => $law->image + 'image' => $law->image, ]; } diff --git a/app/Http/Controllers/api/AuthController.php b/app/Http/Controllers/api/AuthController.php index fc866dd..473fc1c 100644 --- a/app/Http/Controllers/api/AuthController.php +++ b/app/Http/Controllers/api/AuthController.php @@ -24,7 +24,7 @@ class AuthController extends Controller return User::create([ 'name' => 'Law', 'mobile' => $request->mobile, - 'email' => 'law' . $request->mobile . '@law.com', + 'email' => 'law'.$request->mobile.'@law.com', 'password' => Hash::make($request->mobile), ]); }); diff --git a/app/Http/Controllers/api/BookController.php b/app/Http/Controllers/api/BookController.php index cba6bca..dd214fe 100644 --- a/app/Http/Controllers/api/BookController.php +++ b/app/Http/Controllers/api/BookController.php @@ -6,7 +6,6 @@ use App\Http\Controllers\Controller; use App\Http\Requests\BookRequest; use App\Models\Book; use App\Models\Law; -use App\Models\Order; use App\Traits\BaseApiResponse; class BookController extends Controller @@ -24,7 +23,7 @@ class BookController extends Controller $books->getCollection()->transform(function ($section) { $section['is_locked'] = auth()->user()->isSubscriber() !== false ? false : Law::where('id', $section['law_id'])->first()?->is_locked ?? false; - + unset($section['law_id']); unset($section['volum_id']); diff --git a/app/Http/Controllers/api/CategoriesController.php b/app/Http/Controllers/api/CategoriesController.php index 9d3a7c5..08f5990 100644 --- a/app/Http/Controllers/api/CategoriesController.php +++ b/app/Http/Controllers/api/CategoriesController.php @@ -12,13 +12,12 @@ class CategoriesController extends Controller use BaseApiResponse; public function index(Request $request) - { + { $perPage = $request->input('per_page', 15); $page = $request->input('page', 1); $categories = Category::paginate($perPage, ['*'], 'page', $page); - return $this->success($categories->items()); } } diff --git a/app/Http/Controllers/api/ChapterController.php b/app/Http/Controllers/api/ChapterController.php index cb2809a..d07e7ca 100644 --- a/app/Http/Controllers/api/ChapterController.php +++ b/app/Http/Controllers/api/ChapterController.php @@ -6,7 +6,6 @@ use App\Http\Controllers\Controller; use App\Http\Requests\ChapterRequest; use App\Models\Chapter; use App\Models\Law; -use App\Models\Order; use App\Traits\BaseApiResponse; class ChapterController extends Controller @@ -20,7 +19,7 @@ class ChapterController extends Controller $perPage = $validated['per_page'] ?? 15; $page = $validated['page'] ?? 1; - $chapters = Chapter::where('book_id' , $validated['book_id'])->paginate($perPage, ['*'], 'page', $page); + $chapters = Chapter::where('book_id', $validated['book_id'])->paginate($perPage, ['*'], 'page', $page); $chapters->getCollection()->transform(function ($section) { diff --git a/app/Http/Controllers/api/FolderController.php b/app/Http/Controllers/api/FolderController.php index b62f825..2a30af7 100644 --- a/app/Http/Controllers/api/FolderController.php +++ b/app/Http/Controllers/api/FolderController.php @@ -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([], 'حذف شد', 'ارت با موفقیت حذف شد'); } } diff --git a/app/Http/Controllers/api/GateController.php b/app/Http/Controllers/api/GateController.php index a596182..828333f 100644 --- a/app/Http/Controllers/api/GateController.php +++ b/app/Http/Controllers/api/GateController.php @@ -6,9 +6,7 @@ use App\Http\Controllers\Controller; use App\Http\Requests\ChapterRequest; use App\Models\Gate; use App\Models\Law; -use App\Models\Order; use App\Traits\BaseApiResponse; -use Illuminate\Http\Request; class GateController extends Controller { @@ -23,15 +21,13 @@ class GateController extends Controller $gates->getCollection()->transform(function ($gate) { unset($gate['book_id']); - $gate['is_locked'] = auth()->user()->isSubscriber() !== false ? false : Law::where('id', $gate['law_id'])->first()?->is_locked; + $gate['is_locked'] = auth()->user()->isSubscriber() !== false ? false : Law::where('id', $gate['law_id'])->first()?->is_locked; unset($gate['law_id']); return $gate; }); - - return $this->success($gates->items()); } } diff --git a/app/Http/Controllers/api/HomeController.php b/app/Http/Controllers/api/HomeController.php index 0fb1802..d0c9cf1 100644 --- a/app/Http/Controllers/api/HomeController.php +++ b/app/Http/Controllers/api/HomeController.php @@ -29,7 +29,7 @@ class HomeController extends Controller return [ 'id' => $q->law?->id, 'name' => $q->law?->title, - 'is_locked' => $q->law?->is_locked + 'is_locked' => $q->law?->is_locked, ]; }); @@ -37,7 +37,7 @@ class HomeController extends Controller return [ 'id' => $q->id, 'name' => $q->title, - 'is_locked' => $q->is_locked + 'is_locked' => $q->is_locked, ]; }); @@ -49,13 +49,13 @@ class HomeController extends Controller $q->where('type', $category); })->get()->map(function ($q) { return [ - "id" => $q->id, - "title" => $q->title, - "is_locked" => $q->is_locked, - "category_id" => $q->category_id, - "price" => $q->price, - "image" => $q->image, - "type" => 'law' + 'id' => $q->id, + 'title' => $q->title, + 'is_locked' => $q->is_locked, + 'category_id' => $q->category_id, + 'price' => $q->price, + 'image' => $q->image, + 'type' => 'law', ]; }); } @@ -64,7 +64,7 @@ class HomeController extends Controller return [ 'id' => $q->id, 'name' => $q->title, - 'is_locked' => $q->is_locked + 'is_locked' => $q->is_locked, ]; }); @@ -83,7 +83,7 @@ class HomeController extends Controller 'name' => $freeSubscription->subscribe->name, 'price' => $freeSubscription->subscribe->price, 'expired_day' => $freeSubscription->expired_at->diffInDays(now()), - 'is_free' => true + 'is_free' => true, ]; } @@ -92,7 +92,9 @@ class HomeController extends Controller ->latest('expired_at') ->first(); - $expiredDays = UserSubscriber::query()->where('user_id', $user->id)->where('expired_at', '>=', now())->get()->sum(function ($subscriber) {return $subscriber->expired_at->diffInDays(now());}); + $expiredDays = UserSubscriber::query()->where('user_id', $user->id)->where('expired_at', '>=', now())->get()->sum(function ($subscriber) { + return $subscriber->expired_at->diffInDays(now()); + }); if ($latestSubscription) { $current_plan = [ @@ -100,7 +102,7 @@ class HomeController extends Controller 'name' => $latestSubscription->subscribe->name ?? 'Subscription', 'price' => $latestSubscription->subscribe->price ?? 100, 'expired_day' => $expiredDays, - 'is_free' => (bool) $latestSubscription->is_free + 'is_free' => (bool) $latestSubscription->is_free, ]; } @@ -119,9 +121,9 @@ class HomeController extends Controller private function refreshMarketSubscriptionAfterResponse($user): void { $cacheKey = "home-market-refresh-user-{$user->id}"; - $this->refreshMarketSubscription($user); + $this->refreshMarketSubscription($user); - if (!Cache::add($cacheKey, true, now()->addHours(24))) { + if (! Cache::add($cacheKey, true, now()->addHours(24))) { return; } @@ -164,6 +166,6 @@ class HomeController extends Controller return true; } - return !$subscriber->last_verified_at || $subscriber->last_verified_at->lessThan(now()->subHours(12)); + return ! $subscriber->last_verified_at || $subscriber->last_verified_at->lessThan(now()->subHours(12)); } } diff --git a/app/Http/Controllers/api/LawController.php b/app/Http/Controllers/api/LawController.php index 6303255..da99fe0 100644 --- a/app/Http/Controllers/api/LawController.php +++ b/app/Http/Controllers/api/LawController.php @@ -15,9 +15,9 @@ class LawController extends Controller { $perPage = $request->input('per_page', 15); $page = $request->input('page', 1); - + $laws = Law::simplePaginate($perPage, ['*'], 'page', $page); - + return $this->success($laws->items(), 'Success'); } } diff --git a/app/Http/Controllers/api/NoteController.php b/app/Http/Controllers/api/NoteController.php index 1c55877..00d86fa 100644 --- a/app/Http/Controllers/api/NoteController.php +++ b/app/Http/Controllers/api/NoteController.php @@ -16,7 +16,7 @@ class NoteController extends Controller $validated = $request->validate([ 'art_id' => 'required', 'note' => 'required', - 'color_code' => 'nullable' + 'color_code' => 'nullable', ]); Note::query()->create( @@ -36,7 +36,7 @@ class NoteController extends Controller { $validated = $request->validate([ 'note' => 'required', - 'color_code' => 'nullable' + 'color_code' => 'nullable', ]); $note = Note::findOrFail($id); diff --git a/app/Http/Controllers/api/PartController.php b/app/Http/Controllers/api/PartController.php index 1fb042b..ea55b9b 100644 --- a/app/Http/Controllers/api/PartController.php +++ b/app/Http/Controllers/api/PartController.php @@ -5,34 +5,31 @@ namespace App\Http\Controllers\api; use App\Http\Controllers\Controller; use App\Http\Requests\ChapterRequest; use App\Models\Law; -use App\Models\Order; use App\Models\Part; use App\Traits\BaseApiResponse; -use Illuminate\Http\Request; class PartController extends Controller { use BaseApiResponse; public function index(ChapterRequest $request) - { + { $validated = $request->validated(); - + $perPage = $request->input('per_page', 15); $page = $request->input('page', 1); - $parts = Part::where('book_id' , $request->input('book_id'))->paginate($perPage, ['*'], 'page', $page); + $parts = Part::where('book_id', $request->input('book_id'))->paginate($perPage, ['*'], 'page', $page); $parts->getCollection()->transform(function ($part) { unset($part['book_id']); - $part['is_locked'] = auth()->user()->isSubscriber() !== false ? false : Law::where('id', $part['law_id'])->first()?->is_locked; + $part['is_locked'] = auth()->user()->isSubscriber() !== false ? false : Law::where('id', $part['law_id'])->first()?->is_locked; unset($part['law_id']); return $part; }); - return $this->success($parts->items()); } } diff --git a/app/Http/Controllers/api/PayController.php b/app/Http/Controllers/api/PayController.php index e0fc0d3..82aa9bc 100644 --- a/app/Http/Controllers/api/PayController.php +++ b/app/Http/Controllers/api/PayController.php @@ -3,7 +3,6 @@ namespace App\Http\Controllers\api; use App\Http\Controllers\Controller; -use App\Models\Order; use App\Models\PaymentTransaction; use App\Models\SubscribePlan; use App\Models\UserSubscriber; @@ -29,7 +28,7 @@ class PayController extends Controller $invoice = (new Invoice)->amount($subscribePlan->price); $callback = 'https://ghaafapp.ir'; - $payment = Payment::callbackUrl($callback . '/payment/callback') + $payment = Payment::callbackUrl($callback.'/payment/callback') ->purchase($invoice, function ($driver, $transaction_id) use ($subscribePlan) { PaymentTransaction::create([ 'user_id' => auth()->user()->id, @@ -43,7 +42,8 @@ class PayController extends Controller return $this->success(['url' => $payment]); } catch (\Exception $e) { - Log::error('Payment initiation failed: ' . $e->getMessage()); + Log::error('Payment initiation failed: '.$e->getMessage()); + return $this->failed('Payment initialization failed', $e->getMessage()); } } @@ -78,20 +78,21 @@ class PayController extends Controller return $this->failed([], ['title' => 'Payment Failed', 'message' => 'Payment verification failed.']); } catch (\Exception $e) { Log::info('error in callback function', ['error' => $e->getMessage()]); + return $this->failed([], ['title' => 'Payment Failed', 'message' => 'Payment verification failed.']); } } - private function send($url, $api, $amount, $redirect, $factorId, $name, $email, $description) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POSTFIELDS, "api=$api&amount=$amount&redirect=$redirect&factorId=$factorId&name=$name&email=$email&description=$description"); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $res = curl_exec($ch); curl_close($ch); + return $res; } @@ -100,10 +101,11 @@ class PayController extends Controller $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POSTFIELDS, "api=$api&id_get=$id_get&trans_id=$trans_id&json=1"); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $res = curl_exec($ch); curl_close($ch); + return $res; } } diff --git a/app/Http/Controllers/api/SectionController.php b/app/Http/Controllers/api/SectionController.php index 6dcf41c..40e7113 100644 --- a/app/Http/Controllers/api/SectionController.php +++ b/app/Http/Controllers/api/SectionController.php @@ -6,7 +6,6 @@ use App\Http\Controllers\Controller; use App\Http\Requests\SectionRequest; use App\Models\Law; use App\Models\LikeSection; -use App\Models\Order; use App\Models\Section; use App\Traits\BaseApiResponse; @@ -26,7 +25,7 @@ class SectionController extends Controller $section->getCollection()->transform(function ($section) { unset($section['book_id']); $section['is_locked'] = auth()->user()->isSubscriber() !== false ? false : Law::where('id', $section['law_id'])->first()?->is_locked; - + unset($section['law_id']); return $section; diff --git a/app/Http/Controllers/api/SubscribePlanController.php b/app/Http/Controllers/api/SubscribePlanController.php index 0394db9..9e34eca 100644 --- a/app/Http/Controllers/api/SubscribePlanController.php +++ b/app/Http/Controllers/api/SubscribePlanController.php @@ -30,6 +30,7 @@ class SubscribePlanController extends Controller return null; } } + return [ 'id' => $q->id, 'name' => $q->name, @@ -37,7 +38,7 @@ class SubscribePlanController extends Controller 'expired_day' => $q->expired_day, 'is_free' => $q->is_free == 1 ? true : false, 'type' => $q->type, - 'transaction' => $q->transaction + 'transaction' => $q->transaction, ]; })->filter(function ($q) { @@ -60,7 +61,7 @@ class SubscribePlanController extends Controller ->where('expired_at', '>', now()) ->first(); - if ($activeSubscription && !$activeSubscription?->subscribe?->is_free && !$subscribePlan->is_free) { + if ($activeSubscription && ! $activeSubscription?->subscribe?->is_free && ! $subscribePlan->is_free) { return $this->failed(null, ['title' => 'Subscribe Plan', 'message' => 'You already have an active subscription. Please wait until it expires.']); } @@ -102,7 +103,8 @@ class SubscribePlanController extends Controller return $this->success(['url' => $payment]); } catch (\Exception $e) { - Log::error('Payment initiation failed: ' . $e->getMessage()); + Log::error('Payment initiation failed: '.$e->getMessage()); + return $this->failed(null, 'درگاه پرداخت در دسترس نیست'); } } @@ -112,7 +114,7 @@ class SubscribePlanController extends Controller $request->validate([ 'subscribe_plan_id' => 'required|exists:subscribe_plans,id', 'subscription_id' => 'nullable', - 'purchase_token' => 'nullable' + 'purchase_token' => 'nullable', ]); $subscribePlan = SubscribePlan::findOrFail($request->subscribe_plan_id); @@ -139,7 +141,7 @@ class SubscribePlanController extends Controller $user->userSubscribers()->create([ 'subscribe_plan_id' => $subscribePlan->id, 'expired_at' => $expiredAt, - 'is_free' => true + 'is_free' => true, ]); return $this->success(null, 'Subscribe Plan', 'Free Subscribe Plan Successfully Activated'); @@ -148,14 +150,14 @@ class SubscribePlanController extends Controller $subscription_id = $request->input('subscription_id'); $purchase_token = $request->input('purchase_token'); - if (!$subscription_id || !$purchase_token) { + if (! $subscription_id || ! $purchase_token) { return $this->failed(null, ['title' => 'Subscribe Plan', 'message' => 'Invalid subscription details.']); } try { $bazaarExpiredAt = $this->marketVerifier->verifyBazaarSubscription($subscription_id, $purchase_token); - if (!$bazaarExpiredAt) { + if (! $bazaarExpiredAt) { return $this->failed(null, ['title' => 'Subscribe Plan', 'message' => 'Invalid or expired subscription.']); } @@ -172,12 +174,13 @@ class SubscribePlanController extends Controller 'purchase_token' => $purchase_token, 'market_provider' => 'bazaar', 'last_verified_at' => now(), - 'is_free' => false + 'is_free' => false, ]); return $this->success(null, 'Subscribe Plan', 'Subscription successfully activated.'); } catch (\Exception $e) { Log::error('Error in subscription', ['Error' => $e->getMessage()]); + return $this->failed(null, ['title' => 'Subscribe Plan', 'message' => 'Failed to verify subscription.']); } } @@ -207,7 +210,7 @@ class SubscribePlanController extends Controller try { $purchase = $this->marketVerifier->verifyMyketProduct($request->sku_id, $token); - if (!$purchase) { + if (! $purchase) { return $this->failed(null, ['title' => 'Subscribe Plan', 'message' => 'Invalid or failed Myket purchase.']); } @@ -306,16 +309,16 @@ class SubscribePlanController extends Controller return $this->success(null, 'Subscribe Plan', 'No Subscribe Plan'); } - private function send($url, $api, $amount, $redirect, $factorId, $name, $email, $description) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POSTFIELDS, "api=$api&amount=$amount&redirect=$redirect&factorId=$factorId&name=$name&email=$email&description=$description"); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $res = curl_exec($ch); curl_close($ch); + return $res; } @@ -324,10 +327,11 @@ class SubscribePlanController extends Controller $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POSTFIELDS, "api=$api&id_get=$id_get&trans_id=$trans_id&json=1"); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $res = curl_exec($ch); curl_close($ch); + return $res; } } diff --git a/app/Http/Controllers/api/VersionController.php b/app/Http/Controllers/api/VersionController.php index a8572fc..abeffbd 100644 --- a/app/Http/Controllers/api/VersionController.php +++ b/app/Http/Controllers/api/VersionController.php @@ -15,18 +15,18 @@ class VersionController extends Controller { $version = Version::query()->where('type', $versionRequest->type)->orderBy('id', 'desc')->first(); - if (!$version) { + if (! $version) { return $this->failed([], 'Version not found'); } if (intval($version->number) > $versionRequest->number) { return $this->success([ - 'force_update' => $version->force_update == 1 ? true : false + 'force_update' => $version->force_update == 1 ? true : false, ], 'Your app need to be updated'); } return $this->success([ - 'force_update' => false + 'force_update' => false, ], 'Version successfully'); } } diff --git a/app/Http/Controllers/api/VolumController.php b/app/Http/Controllers/api/VolumController.php index 929dcde..b49c42e 100644 --- a/app/Http/Controllers/api/VolumController.php +++ b/app/Http/Controllers/api/VolumController.php @@ -14,7 +14,6 @@ use App\Models\Chapter; use App\Models\Division; use App\Models\Gate; use App\Models\Law; -use App\Models\Order; use App\Models\Part; use App\Models\RecentArt; use App\Models\Section; @@ -35,7 +34,7 @@ class VolumController extends Controller $volumes->getCollection()->transform(function ($volume) { $volume['has_book'] = Book::where('volum_id', $volume->id)->exists(); - $volume['is_locked'] = auth()->user()->isSubscriber() !== false ? false : Law::where('id', $volume['law_id'])->first()?->is_locked; + $volume['is_locked'] = auth()->user()->isSubscriber() !== false ? false : Law::where('id', $volume['law_id'])->first()?->is_locked; unset($volume['law_id']); @@ -63,7 +62,7 @@ class VolumController extends Controller $book = Book::with(['divisions', 'sections', 'gates', 'parts', 'chapters', 'branchs', 'art']) ->find($bookId); - if (!$book) { + if (! $book) { return $this->success([], 'Book not found'); } @@ -79,7 +78,7 @@ class VolumController extends Controller 'title' => $item->title, 'number' => $item->number, 'type' => $relation, - 'is_locked' => auth()->user()->isSubscriber() !== false ? false : Law::where('id', $item->law_id)->first()?->is_locked + 'is_locked' => auth()->user()->isSubscriber() !== false ? false : Law::where('id', $item->law_id)->first()?->is_locked, ]; } $paginationData = [ @@ -100,11 +99,10 @@ class VolumController extends Controller $division = Division::with(['sections', 'chapters', 'parts', 'gate', 'branch', 'art']) ->find($division_id); - if (!$division) { + if (! $division) { return $this->success([], 'Division not found'); } - $data = []; $foundRelation = false; foreach (['sections', 'chapters', 'parts', 'gate', 'branch', 'art'] as $relation) { @@ -117,7 +115,7 @@ class VolumController extends Controller 'title' => $item->title, 'number' => $item->number, 'type' => $relation, - 'is_locked' => auth()->user()->isSubscriber() !== false ? false : Law::where('id', $item->law_id)->first()?->is_locked + 'is_locked' => auth()->user()->isSubscriber() !== false ? false : Law::where('id', $item->law_id)->first()?->is_locked, ]; } break; @@ -135,7 +133,7 @@ class VolumController extends Controller $section = Section::with(['chapters', 'parts', 'gate', 'branch', 'art']) ->find($section_id); - if (!$section) { + if (! $section) { return $this->success([], 'Section not found'); } @@ -151,7 +149,7 @@ class VolumController extends Controller 'title' => $item->title, 'number' => $item->number, 'type' => $relation, - 'is_locked' => auth()->user()->isSubscriber() !== false ? false : Law::where('id', $item->law_id)->first()?->is_locked + 'is_locked' => auth()->user()->isSubscriber() !== false ? false : Law::where('id', $item->law_id)->first()?->is_locked, ]; } break; @@ -168,7 +166,7 @@ class VolumController extends Controller if ($volumeId) { $volume = Volum::with(['book', 'divisions', 'sections', 'gates', 'parts', 'chapters', 'branchs', 'art']) ->find($volumeId); - if (!$volume) { + if (! $volume) { return $this->success([], 'Volume not found'); } @@ -184,7 +182,7 @@ class VolumController extends Controller 'title' => $item->title, 'number' => $item->number, 'type' => $relation, - 'is_locked' => auth()->user()->isSubscriber() !== false ? false : Law::where('id', $item->law_id)->first()?->is_locked + 'is_locked' => auth()->user()->isSubscriber() !== false ? false : Law::where('id', $item->law_id)->first()?->is_locked, ]; } break; @@ -202,7 +200,7 @@ class VolumController extends Controller $part = Part::with(['gate', 'branch', 'art']) ->find($part_id); - if (!$part) { + if (! $part) { return $this->success([], 'Part not found'); } @@ -218,7 +216,7 @@ class VolumController extends Controller 'title' => $item->title, 'number' => $item->number, 'type' => $relation, - 'is_locked' => auth()->user()->isSubscriber() !== false ? false : Law::where('id', $item->law_id)->first()?->is_locked + 'is_locked' => auth()->user()->isSubscriber() !== false ? false : Law::where('id', $item->law_id)->first()?->is_locked, ]; } break; @@ -236,7 +234,7 @@ class VolumController extends Controller $chapter = Chapter::with(['parts', 'gate', 'branch', 'art']) ->find($chapter_id); - if (!$chapter) { + if (! $chapter) { return $this->success([], 'Chapter not found'); } @@ -252,7 +250,7 @@ class VolumController extends Controller 'title' => $item->title, 'number' => $item->number, 'type' => $relation, - 'is_locked' => auth()->user()->isSubscriber() !== false ? false : Law::where('id', $item->law_id)->first()?->is_locked + 'is_locked' => auth()->user()->isSubscriber() !== false ? false : Law::where('id', $item->law_id)->first()?->is_locked, ]; } break; @@ -270,7 +268,7 @@ class VolumController extends Controller $branch = Branch::with(['art']) ->find($branch_id); - if (!$branch) { + if (! $branch) { return $this->success([], 'Branch not found'); } @@ -286,7 +284,7 @@ class VolumController extends Controller 'title' => $item->title, 'number' => $item->number, 'type' => $relation, - 'is_locked' => auth()->user()->isSubscriber() !== false ? false : Law::where('id', $item->law_id)->first()?->is_locked + 'is_locked' => auth()->user()->isSubscriber() !== false ? false : Law::where('id', $item->law_id)->first()?->is_locked, ]; } break; @@ -300,12 +298,11 @@ class VolumController extends Controller } } - if ($gate_id) { $gate = Gate::with(['branch', 'art']) ->find($gate_id); - if (!$gate) { + if (! $gate) { return $this->success([], 'Gate not found'); } @@ -321,7 +318,7 @@ class VolumController extends Controller 'title' => $item->title, 'number' => $item->number, 'type' => $relation, - 'is_locked' => auth()->user()->isSubscriber() !== false ? false : Law::where('id', $item->law_id)->first()?->is_locked + 'is_locked' => auth()->user()->isSubscriber() !== false ? false : Law::where('id', $item->law_id)->first()?->is_locked, ]; } break; @@ -339,7 +336,7 @@ class VolumController extends Controller $volume = Volum::with(['book', 'divisions', 'sections', 'gates', 'parts', 'chapters', 'branchs']) ->find($volumeId); - if (!$volume) { + if (! $volume) { return $this->success([], 'Volume not found'); } @@ -355,7 +352,7 @@ class VolumController extends Controller 'title' => $item->title, 'number' => $item->number, 'type' => $relation, - 'is_locked' => auth()->user()->isSubscriber() !== false ? false : Law::where('id', $item->law_id)->first()?->is_locked + 'is_locked' => auth()->user()->isSubscriber() !== false ? false : Law::where('id', $item->law_id)->first()?->is_locked, ]; } break; @@ -372,7 +369,7 @@ class VolumController extends Controller if ($law_Id) { $law = Law::find($law_Id); - if (!$law) { + if (! $law) { return $this->success([], 'Law not found'); } @@ -380,16 +377,14 @@ class VolumController extends Controller ->where('law_id', $law->id) ->get(); - RecentArt::query()->updateOrCreate([ 'user_id' => auth()->user()->id, - 'law_id' => $law_Id + 'law_id' => $law_Id, ], [ 'user_id' => auth()->user()->id, - 'law_id' => $law_Id + 'law_id' => $law_Id, ]); - $data = []; if (count($arts) > 0) { @@ -399,9 +394,10 @@ class VolumController extends Controller 'title' => $item->title, 'number' => $item->number, 'type' => 'volume', - 'is_locked' => auth()->user()->isSubscriber() !== false ? false : Law::where('id', $law->id)->first()?->is_locked + 'is_locked' => auth()->user()->isSubscriber() !== false ? false : Law::where('id', $law->id)->first()?->is_locked, ]; } + return $this->success($data, 'Success'); } @@ -423,9 +419,10 @@ class VolumController extends Controller 'title' => $item->title, 'number' => $item->number, 'type' => 'art', - 'is_locked' => auth()->user()->isSubscriber() !== false ? false : Law::where('id', $law->id)->first()?->is_locked + 'is_locked' => auth()->user()->isSubscriber() !== false ? false : Law::where('id', $law->id)->first()?->is_locked, ]; } + return $this->success($data, 'Success'); } @@ -504,8 +501,8 @@ class VolumController extends Controller 'foreign_key' => 'branch_id', 'type' => (new Art)->getTable(), 'check_mode' => Art::class, - 'check_key' => 'branch_id' - ] + 'check_key' => 'branch_id', + ], ]; foreach ($filters as $filterKey => $filterInfo) { @@ -533,7 +530,7 @@ class VolumController extends Controller 'title' => $item?->title, 'number' => $item?->number, 'type' => $type, - 'is_end' => $check_model::where($check_key, $item?->id)->count() !== 0 ? false : true + 'is_end' => $check_model::where($check_key, $item?->id)->count() !== 0 ? false : true, ]; }); @@ -544,7 +541,6 @@ class VolumController extends Controller return $this->success([], 'No law or book or volume specified'); } - public function check_filter_with_art(CheckBookFilterRequest $request) { $lawId = $request->law_id; @@ -584,7 +580,7 @@ class VolumController extends Controller if ($lawId) { $law = Law::with(['volums', 'divisions', 'sections', 'gates', 'parts', 'chapters', 'branchs', 'arts'])->find($lawId); - if (!$law) { + if (! $law) { return $this->success([], 'Law not found'); } @@ -596,10 +592,9 @@ class VolumController extends Controller return $this->success([], 'No related records found in the law'); } - if ($bookId) { $book = Book::with(['divisions', 'sections', 'gates', 'parts', 'chapters', 'branchs', 'art'])->find($bookId); - if (!$book) { + if (! $book) { return $this->success([], 'Book not found'); } @@ -613,7 +608,7 @@ class VolumController extends Controller if ($volumeId) { $volume = Volum::with(['book', 'divisions', 'sections', 'gates', 'parts', 'chapters', 'branchs', 'art'])->find($volumeId); - if (!$volume) { + if (! $volume) { return $this->success([], 'Volume not found'); } @@ -627,7 +622,7 @@ class VolumController extends Controller if ($sectionId) { $section = Section::with(['gates', 'parts', 'chapters', 'branchs', 'art'])->find($sectionId); - if (!$section) { + if (! $section) { return $this->success([], 'Section not found'); } @@ -641,7 +636,7 @@ class VolumController extends Controller if ($divisionId) { $division = Division::with(['gates', 'parts', 'chapters', 'branchs', 'art'])->find($divisionId); - if (!$division) { + if (! $division) { return $this->success([], 'Division not found'); } @@ -655,7 +650,7 @@ class VolumController extends Controller if ($partId) { $part = Part::with(['gates', 'art'])->find($partId); - if (!$part) { + if (! $part) { return $this->success([], 'Part not found'); } @@ -669,7 +664,7 @@ class VolumController extends Controller if ($branchId) { $branch = Branch::with(['gates', 'chapters', 'art'])->find($branchId); - if (!$branch) { + if (! $branch) { return $this->success([], 'Branch not found'); } @@ -683,7 +678,7 @@ class VolumController extends Controller if ($chapterId) { $chapter = Chapter::with(['gate', 'parts', 'art'])->find($chapterId); - if (!$chapter) { + if (! $chapter) { return $this->success([], 'Chapter not found'); } @@ -697,7 +692,7 @@ class VolumController extends Controller if ($gateId) { $gate = Gate::with(['art'])->find($gateId); - if (!$gate) { + if (! $gate) { return $this->success([], 'Gate not found'); } @@ -712,7 +707,6 @@ class VolumController extends Controller return $this->success([], 'No valid filter specified'); } - private function prepareItemsData($items, $type) { $data = []; @@ -724,14 +718,15 @@ class VolumController extends Controller 'number' => $item->number, 'type' => $type, 'route' => $this->route($item, $item), - 'is_locked' => auth()->user()->isSubscriber() !== false ? false : Law::where('id', $item->law_id)->first()?->is_locked, + 'is_locked' => auth()->user()->isSubscriber() !== false ? false : Law::where('id', $item->law_id)->first()?->is_locked, 'law' => $law?->title, 'image' => $law?->image, - 'count_art' => $law?->arts?->count() ?? 0, + 'count_art' => $law?->arts?->count() ?? 0, 'count_volums' => $law?->volums?->count() ?? 0, 'price' => $law?->price, ]; } + return $data; } @@ -740,13 +735,14 @@ class VolumController extends Controller foreach ($relations as $relation) { if ($model->{$relation} && $model->{$relation}->count() > 0) { $items = $model->{$relation}()->paginate($perPage); + return $this->prepareItemsData($items, $relation); } } + return null; } - private function convertValueTo($var) { switch ($var) { @@ -769,13 +765,13 @@ class VolumController extends Controller switch ((new $modelClass)->getTable()) { case 'laws': $route = array_filter([ - Law::find($query->id)?->title + Law::find($query->id)?->title, ]); break; case 'volums': $route = array_filter([ Law::find($query->law_id)?->title, - Volum::find($query->id)?->title + Volum::find($query->id)?->title, ]); break; case 'books': diff --git a/app/Http/Requests/GetApiRequest.php b/app/Http/Requests/GetApiRequest.php index dcff485..c4e8b90 100644 --- a/app/Http/Requests/GetApiRequest.php +++ b/app/Http/Requests/GetApiRequest.php @@ -17,7 +17,7 @@ class GetApiRequest extends FormRequest public function rules(): array { return [ - 'book_id' => 'required' + 'book_id' => 'required', ]; } } diff --git a/app/Http/Requests/SuggestionRequest.php b/app/Http/Requests/SuggestionRequest.php index ddd5513..a8340db 100644 --- a/app/Http/Requests/SuggestionRequest.php +++ b/app/Http/Requests/SuggestionRequest.php @@ -25,7 +25,7 @@ class SuggestionRequest extends FormRequest public function rules(): array { return [ - 'text' => 'required' + 'text' => 'required', ]; } } diff --git a/app/Http/Requests/admin/CreateVersionStore.php b/app/Http/Requests/admin/CreateVersionStore.php index acc871e..42599b0 100644 --- a/app/Http/Requests/admin/CreateVersionStore.php +++ b/app/Http/Requests/admin/CreateVersionStore.php @@ -18,7 +18,7 @@ class CreateVersionStore extends FormRequest 'number' => 'required', 'log' => 'required', 'force_update' => 'nullable', - 'type' => 'required' + 'type' => 'required', ]; } } diff --git a/app/Http/Requests/admin/SubscribePlan/CreateRequest.php b/app/Http/Requests/admin/SubscribePlan/CreateRequest.php index eddf9c9..ff156cc 100644 --- a/app/Http/Requests/admin/SubscribePlan/CreateRequest.php +++ b/app/Http/Requests/admin/SubscribePlan/CreateRequest.php @@ -28,7 +28,7 @@ class CreateRequest extends FormRequest 'is_active' => 'nullable', 'is_free' => 'nullable', 'type' => 'nullable', - 'transaction' => 'nullable' + 'transaction' => 'nullable', ]; } } diff --git a/app/Http/Requests/admin/SubscribePlan/UpdateRequest.php b/app/Http/Requests/admin/SubscribePlan/UpdateRequest.php index 2fd1a29..0cff846 100644 --- a/app/Http/Requests/admin/SubscribePlan/UpdateRequest.php +++ b/app/Http/Requests/admin/SubscribePlan/UpdateRequest.php @@ -28,7 +28,7 @@ class UpdateRequest extends FormRequest 'is_active' => 'nullable', 'is_free' => 'nullable', 'type' => 'nullable', - 'transaction' => 'nullable' + 'transaction' => 'nullable', ]; } } diff --git a/app/Http/Requests/admin/UpdateVersionStore.php b/app/Http/Requests/admin/UpdateVersionStore.php index 41c0ffd..301ce82 100644 --- a/app/Http/Requests/admin/UpdateVersionStore.php +++ b/app/Http/Requests/admin/UpdateVersionStore.php @@ -17,8 +17,8 @@ class UpdateVersionStore extends FormRequest 'code' => 'required', 'number' => 'required', 'log' => 'required', - 'force_update' => 'nullable', - 'type' => 'required' + 'force_update' => 'nullable', + 'type' => 'required', ]; } } diff --git a/app/Jobs/CheckBazaarSubscription.php b/app/Jobs/CheckBazaarSubscription.php index b7eaee3..8e844d1 100644 --- a/app/Jobs/CheckBazaarSubscription.php +++ b/app/Jobs/CheckBazaarSubscription.php @@ -3,13 +3,13 @@ namespace App\Jobs; // These are the classes we need to import for our job to work +use App\Models\UserSubscriber; +use Carbon\Carbon; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; -use Illuminate\Queue\InteractsWithQueue; +use Illuminate\Queue\InteractsWithQueue; // Your model for tracking user subscriptions use Illuminate\Queue\SerializesModels; -use App\Models\UserSubscriber; // Your model for tracking user subscriptions -use Carbon\Carbon; use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Log; @@ -40,8 +40,9 @@ class CheckBazaarSubscription implements ShouldQueue $package_name = 'com.razzaghi.lawbook.android'; // Your app's package name // If there's no purchase token, we can't do anything, so we stop. - if (!$purchase_token) { - Log::info('Job skipped: No purchase token for UserSubscriber ID: ' . $this->userSubscriber->id); + if (! $purchase_token) { + Log::info('Job skipped: No purchase token for UserSubscriber ID: '.$this->userSubscriber->id); + return; } @@ -69,16 +70,16 @@ class CheckBazaarSubscription implements ShouldQueue // If the expiration date in our database is different, update it if ($this->userSubscriber->expired_at->notEqualTo($bazaarExpiredAt)) { $this->userSubscriber->update(['expired_at' => $bazaarExpiredAt]); - Log::info('Subscription date updated for user: ' . $this->userSubscriber->user_id); + Log::info('Subscription date updated for user: '.$this->userSubscriber->user_id); } } else { // If the subscription is no longer valid, update it in our database to expire now $this->userSubscriber->update(['expired_at' => now()]); - Log::warning('Subscription found expired on Bazaar for user: ' . $this->userSubscriber->user_id); + Log::warning('Subscription found expired on Bazaar for user: '.$this->userSubscriber->user_id); } } else { - // If the API call failed, log the error for debugging - Log::error('Failed to fetch subscription from Bazaar', ['status' => $response->status(), 'body' => $response->body()]); + // If the API call failed, log the error for debugging + Log::error('Failed to fetch subscription from Bazaar', ['status' => $response->status(), 'body' => $response->body()]); } } catch (\Exception $e) { @@ -86,4 +87,4 @@ class CheckBazaarSubscription implements ShouldQueue Log::error('Exception while checking Bazaar subscription', ['error' => $e->getMessage()]); } } -} \ No newline at end of file +} diff --git a/app/Models/Book.php b/app/Models/Book.php index d896e9e..d68c88b 100644 --- a/app/Models/Book.php +++ b/app/Models/Book.php @@ -48,7 +48,6 @@ class Book extends Model return $this->hasMany(Branch::class); } - public static function searchLimit($searchTerm) { return self::where('title', 'LIKE', "%{$searchTerm}%")->limit(3)->get(); diff --git a/app/Models/Branch.php b/app/Models/Branch.php index ef5f9b3..b27acc4 100644 --- a/app/Models/Branch.php +++ b/app/Models/Branch.php @@ -8,9 +8,8 @@ use Illuminate\Database\Eloquent\Model; class Branch extends Model { use HasFactory; - - protected $fillable = ['title', 'number', 'chapter_id', 'part_id', 'volum_id', 'law_id', 'book_id', 'section_id', 'gate_id','division_id']; + protected $fillable = ['title', 'number', 'chapter_id', 'part_id', 'volum_id', 'law_id', 'book_id', 'section_id', 'gate_id', 'division_id']; public function art() { @@ -21,7 +20,7 @@ class Branch extends Model { return self::where('title', 'LIKE', "%{$searchTerm}%")->get(); } - + public static function searchLimit($searchTerm) { return self::where('title', 'LIKE', "%{$searchTerm}%")->limit(3)->get(); diff --git a/app/Models/BylawCodificationLink.php b/app/Models/BylawCodificationLink.php new file mode 100644 index 0000000..6ba83b0 --- /dev/null +++ b/app/Models/BylawCodificationLink.php @@ -0,0 +1,14 @@ + 'boolean']; + + public function category() + { + return $this->belongsTo(BylawSubjectCategory::class, 'category_id'); + } + + public function approvalAuthority() + { + return $this->belongsTo(BylawLegalAuthority::class, 'approval_authority_id'); + } + + public function promulgationAuthority() + { + return $this->belongsTo(BylawLegalAuthority::class, 'promulgation_authority_id'); + } + + public function nodes() + { + return $this->hasMany(BylawNode::class, 'document_id'); + } +} diff --git a/app/Models/BylawLegalAuthority.php b/app/Models/BylawLegalAuthority.php new file mode 100644 index 0000000..0a7f0f9 --- /dev/null +++ b/app/Models/BylawLegalAuthority.php @@ -0,0 +1,12 @@ +belongsTo(BylawDocument::class, 'document_id'); + } + + public function parent() + { + return $this->belongsTo(self::class, 'parent_id'); + } + + public function type() + { + return $this->belongsTo(BylawNodeType::class, 'node_type_id'); + } +} diff --git a/app/Models/BylawNodeType.php b/app/Models/BylawNodeType.php new file mode 100644 index 0000000..a817d3e --- /dev/null +++ b/app/Models/BylawNodeType.php @@ -0,0 +1,12 @@ +belongsTo(self::class, 'parent_id'); + } +} diff --git a/app/Models/Category.php b/app/Models/Category.php index 973c6cd..68d8a37 100644 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -11,22 +11,19 @@ class Category extends Model protected $fillable = [ 'name', - 'type' + 'type', ]; - - public function laws() { return $this->hasMany(Law::class); } - public static function getType() { return [ 'hagigi' => 'حقیقی', - 'kifari' => 'کیفری' + 'kifari' => 'کیفری', ]; } } diff --git a/app/Models/Chapter.php b/app/Models/Chapter.php index ff33a61..4bc907f 100644 --- a/app/Models/Chapter.php +++ b/app/Models/Chapter.php @@ -9,7 +9,7 @@ class Chapter extends Model { use HasFactory; - protected $fillable = ['title', 'number', 'section_id', 'book_id', 'volum_id', 'law_id','division_id']; + protected $fillable = ['title', 'number', 'section_id', 'book_id', 'volum_id', 'law_id', 'division_id']; protected $hidden = ['created_at', 'updated_at']; @@ -28,7 +28,6 @@ class Chapter extends Model return $this->hasMany(Gate::class); } - public function branch() { return $this->hasMany(Branch::class); diff --git a/app/Models/Division.php b/app/Models/Division.php index 75acb2f..50a7ac3 100644 --- a/app/Models/Division.php +++ b/app/Models/Division.php @@ -11,7 +11,6 @@ class Division extends Model protected $fillable = ['title', 'number', 'book_id', 'volum_id', 'law_id']; - public function sections() { return $this->hasMany(Section::class); @@ -47,7 +46,6 @@ class Division extends Model return $this->hasMany(Art::class); } - public function gates() { return $this->hasMany(Gate::class); @@ -67,5 +65,4 @@ class Division extends Model { return self::where('title', 'LIKE', "%{$searchTerm}%")->limit(3)->get(); } - } diff --git a/app/Models/Folder.php b/app/Models/Folder.php index 614e0f8..c5437b5 100644 --- a/app/Models/Folder.php +++ b/app/Models/Folder.php @@ -11,7 +11,7 @@ class Folder extends Model protected $fillable = [ 'user_id', - 'name' + 'name', ]; public function arts() diff --git a/app/Models/FolderArt.php b/app/Models/FolderArt.php index db606ed..fbef57c 100644 --- a/app/Models/FolderArt.php +++ b/app/Models/FolderArt.php @@ -11,11 +11,11 @@ class FolderArt extends Model protected $fillable = [ 'folder_id', - 'art_id' + 'art_id', ]; public function arts() { - return $this->belongsTo(Art::class,'art_id'); + return $this->belongsTo(Art::class, 'art_id'); } } diff --git a/app/Models/Gate.php b/app/Models/Gate.php index db50ec6..3191878 100644 --- a/app/Models/Gate.php +++ b/app/Models/Gate.php @@ -9,7 +9,7 @@ class Gate extends Model { use HasFactory; - protected $fillable = ['title', 'number', 'part_id', 'chapter_id', 'section_id', 'book_id', 'volum_id', 'law_id','division_id']; + protected $fillable = ['title', 'number', 'part_id', 'chapter_id', 'section_id', 'book_id', 'volum_id', 'law_id', 'division_id']; protected $hidden = ['created_at', 'updated_at']; @@ -18,7 +18,6 @@ class Gate extends Model return $this->hasMany(Branch::class); } - public function art() { return $this->hasMany(Art::class); @@ -38,6 +37,4 @@ class Gate extends Model { return self::where('title', 'LIKE', "%{$searchTerm}%")->limit(3)->get(); } - - } diff --git a/app/Models/JudicialPrecedent.php b/app/Models/JudicialPrecedent.php index 306768e..59d79ac 100644 --- a/app/Models/JudicialPrecedent.php +++ b/app/Models/JudicialPrecedent.php @@ -15,7 +15,7 @@ class JudicialPrecedent extends Model 'subject', 'full_text', 'issuing_authority', - 'category_id' + 'category_id', ]; protected $hidden = ['created_at', 'updated_at']; diff --git a/app/Models/Law.php b/app/Models/Law.php index 75afa85..59f7c6b 100644 --- a/app/Models/Law.php +++ b/app/Models/Law.php @@ -9,11 +9,10 @@ class Law extends Model { use HasFactory; - protected $fillable = ['title', 'is_locked', 'category_id', 'price','image']; + protected $fillable = ['title', 'is_locked', 'category_id', 'price', 'image']; protected $hidden = ['created_at', 'updated_at']; - public function category() { return $this->belongsTo(Category::class, 'category_id'); @@ -81,6 +80,6 @@ class Law extends Model public function getImageAttribute($value) { - return $value ? secure_asset('images/' . $value) : null; + return $value ? secure_asset('images/'.$value) : null; } } diff --git a/app/Models/LikeArt.php b/app/Models/LikeArt.php index e8e1824..d17008c 100644 --- a/app/Models/LikeArt.php +++ b/app/Models/LikeArt.php @@ -11,11 +11,11 @@ class LikeArt extends Model protected $fillable = [ 'user_id', - 'art_id' + 'art_id', ]; public function art() { return $this->belongsTo(Art::class); - } + } } diff --git a/app/Models/LikeSection.php b/app/Models/LikeSection.php index 7df88f3..5a7d715 100644 --- a/app/Models/LikeSection.php +++ b/app/Models/LikeSection.php @@ -11,6 +11,6 @@ class LikeSection extends Model protected $fillable = [ 'section_id', - 'user_id' + 'user_id', ]; } diff --git a/app/Models/Note.php b/app/Models/Note.php index 35d377e..2d7b4aa 100644 --- a/app/Models/Note.php +++ b/app/Models/Note.php @@ -13,6 +13,6 @@ class Note extends Model 'user_id', 'art_id', 'note', - 'color_code' + 'color_code', ]; } diff --git a/app/Models/Order.php b/app/Models/Order.php index b4b7ce0..354ecf8 100644 --- a/app/Models/Order.php +++ b/app/Models/Order.php @@ -16,7 +16,6 @@ class Order extends Model 'transaction_id', ]; - public function user() { return $this->belongsTo(User::class); @@ -26,7 +25,7 @@ class Order extends Model { return [ 'paid' => 'پرداخت شده', - 'unpaid' => 'پرداخت نشده' + 'unpaid' => 'پرداخت نشده', ]; } } diff --git a/app/Models/Part.php b/app/Models/Part.php index d275170..da63a25 100644 --- a/app/Models/Part.php +++ b/app/Models/Part.php @@ -9,11 +9,10 @@ class Part extends Model { use HasFactory; - protected $fillable = ['title', 'number', 'chapter_id', 'section_id', 'book_id', 'volum_id', 'law_id','division_id']; + protected $fillable = ['title', 'number', 'chapter_id', 'section_id', 'book_id', 'volum_id', 'law_id', 'division_id']; protected $hidden = ['created_at', 'updated_at']; - public function gates() { return $this->hasMany(Gate::class); @@ -34,7 +33,6 @@ class Part extends Model return self::where('title', 'LIKE', "%{$searchTerm}%")->get(); } - public static function searchLimit($searchTerm) { return self::where('title', 'LIKE', "%{$searchTerm}%")->limit(3)->get(); diff --git a/app/Models/RecentArt.php b/app/Models/RecentArt.php index fb35b7b..f14f0af 100644 --- a/app/Models/RecentArt.php +++ b/app/Models/RecentArt.php @@ -11,10 +11,9 @@ class RecentArt extends Model protected $fillable = [ 'user_id', - 'law_id' + 'law_id', ]; - public function law() { return $this->belongsTo(Law::class); diff --git a/app/Models/Section.php b/app/Models/Section.php index 92b55df..6208f8a 100644 --- a/app/Models/Section.php +++ b/app/Models/Section.php @@ -9,10 +9,10 @@ class Section extends Model { use HasFactory; - protected $fillable = ['title', 'number', 'book_id', 'volum_id', 'law_id','division_id']; + protected $fillable = ['title', 'number', 'book_id', 'volum_id', 'law_id', 'division_id']; protected $hidden = ['created_at', 'updated_at']; - + public function chapters() { return $this->hasMany(Chapter::class); @@ -47,17 +47,14 @@ class Section extends Model { return $this->hasMany(Art::class); } - public static function search($searchTerm) { return self::where('title', 'LIKE', "%{$searchTerm}%")->get(); } - public static function searchLimit($searchTerm) { return self::where('title', 'LIKE', "%{$searchTerm}%")->limit(3)->get(); } } - diff --git a/app/Models/SubscribePlan.php b/app/Models/SubscribePlan.php index 53ddf0f..532c27d 100644 --- a/app/Models/SubscribePlan.php +++ b/app/Models/SubscribePlan.php @@ -16,7 +16,7 @@ class SubscribePlan extends Model 'is_active', 'is_free', 'type', - 'transaction' + 'transaction', ]; public function users() diff --git a/app/Models/Suggestion.php b/app/Models/Suggestion.php index 278cc02..f7aca4a 100644 --- a/app/Models/Suggestion.php +++ b/app/Models/Suggestion.php @@ -8,10 +8,10 @@ use Illuminate\Database\Eloquent\Model; class Suggestion extends Model { use HasFactory; - + protected $fillable = [ 'user_id', - 'text' + 'text', ]; public function user() diff --git a/app/Models/UserSubscriber.php b/app/Models/UserSubscriber.php index 669e663..9a69421 100644 --- a/app/Models/UserSubscriber.php +++ b/app/Models/UserSubscriber.php @@ -19,12 +19,12 @@ class UserSubscriber extends Model 'product_id', 'purchased_at', 'last_verified_at', - 'is_free' + 'is_free', ]; public function subscribe() { - return $this->belongsTo(SubscribePlan::class,'subscribe_plan_id'); + return $this->belongsTo(SubscribePlan::class, 'subscribe_plan_id'); } public function user() diff --git a/app/Models/Version.php b/app/Models/Version.php index a8e7769..7aebb7a 100644 --- a/app/Models/Version.php +++ b/app/Models/Version.php @@ -14,10 +14,9 @@ class Version extends Model 'number', 'log', 'force_update', - 'type' + 'type', ]; - protected $hidden = [ 'created_at', 'updated_at', diff --git a/app/Models/Volum.php b/app/Models/Volum.php index af3d32b..a6b05d1 100644 --- a/app/Models/Volum.php +++ b/app/Models/Volum.php @@ -15,12 +15,14 @@ class Volum extends Model public function law() { - return $this->belongsTo(Law::class); + return $this->belongsTo(Law::class); } + public function book() { return $this->hasMany(Book::class); } + public function sections() { return $this->hasMany(Section::class); diff --git a/app/Services/AppMarketPurchaseVerifier.php b/app/Services/AppMarketPurchaseVerifier.php index 74998bd..15e14ec 100644 --- a/app/Services/AppMarketPurchaseVerifier.php +++ b/app/Services/AppMarketPurchaseVerifier.php @@ -18,8 +18,7 @@ class AppMarketPurchaseVerifier 'CAFEBAZAAR-PISHKHAN-API-SECRET' => config('services.app_markets.bazaar_secret'), ])->get($url); - - if (!$response->successful()) { + if (! $response->successful()) { Log::error('Failed to verify Bazaar subscription', [ 'status' => $response->status(), 'body' => $response->body(), @@ -30,7 +29,7 @@ class AppMarketPurchaseVerifier $validUntil = $response->json('validUntilTimestampMsec'); - if (!$validUntil || $validUntil < now()->timestamp * 1000) { + if (! $validUntil || $validUntil < now()->timestamp * 1000) { return null; } @@ -39,13 +38,13 @@ class AppMarketPurchaseVerifier public function refreshBazaarSubscriber(UserSubscriber $subscriber): bool { - if (!$subscriber->subscription_id || !$subscriber->purchase_token) { + if (! $subscriber->subscription_id || ! $subscriber->purchase_token) { return false; } $expiredAt = $this->verifyBazaarSubscription($subscriber->subscription_id, $subscriber->purchase_token); - if (!$expiredAt) { + if (! $expiredAt) { $subscriber->update(['expired_at' => now()]); return false; @@ -70,7 +69,7 @@ class AppMarketPurchaseVerifier 'tokenId' => $token, ]); - if (!$response->successful()) { + if (! $response->successful()) { Log::error('Failed to verify Myket purchase', [ 'status' => $response->status(), 'body' => $response->body(), @@ -93,13 +92,13 @@ class AppMarketPurchaseVerifier public function refreshMyketSubscriber(UserSubscriber $subscriber): bool { - if (!$subscriber->product_id || !$subscriber->purchase_token || !$subscriber->subscribe) { + if (! $subscriber->product_id || ! $subscriber->purchase_token || ! $subscriber->subscribe) { return false; } $purchase = $this->verifyMyketProduct($subscriber->product_id, $subscriber->purchase_token); - if (!$purchase) { + if (! $purchase) { $subscriber->update(['expired_at' => now()]); return false; diff --git a/config/cors.php b/config/cors.php index 413bb6a..8852fc5 100644 --- a/config/cors.php +++ b/config/cors.php @@ -15,7 +15,7 @@ return [ | */ - 'paths' => ['api/*', 'sanctum/csrf-cookie','images/*'], + 'paths' => ['api/*', 'sanctum/csrf-cookie', 'images/*'], 'allowed_methods' => ['*'], diff --git a/config/payment.php b/config/payment.php index 1718ce3..5e4efe4 100644 --- a/config/payment.php +++ b/config/payment.php @@ -131,8 +131,8 @@ return [ 'apiPaymentUrl' => 'https://napi.jibit.ir/ppg/v3', 'apiKey' => '', 'apiSecret' => '', - // You can change the token storage path in Laravel like this - // 'tokenStoragePath' => function_exists('storage_path') ? storage_path('jibit/') : 'jibit/' + // You can change the token storage path in Laravel like this + // 'tokenStoragePath' => function_exists('storage_path') ? storage_path('jibit/') : 'jibit/' 'tokenStoragePath' => 'jibit/', 'callbackUrl' => 'http://yoursite.com/path/to', 'description' => 'payment using jibit', @@ -248,9 +248,9 @@ return [ 'PaymentIdentity' => '', 'MultiIdentityRows' => [ [ - "IbanNumber" => '', // Sheba number (with IR) - "Amount" => 0, - "PaymentIdentity" => '', + 'IbanNumber' => '', // Sheba number (with IR) + 'Amount' => 0, + 'PaymentIdentity' => '', ], ], 'description' => 'payment using sadad', @@ -414,13 +414,13 @@ return [ 'base_url' => 'https://escrow-api.toman.ir/api/v1', 'shop_slug' => '', 'auth_code' => '', - 'data' => '' + 'data' => '', ], 'bitpay' => [ 'apiPurchaseUrl' => 'http://bitpay.ir/payment/gateway-send', 'apiPaymentUrl' => 'http://bitpay.ir/payment/gateway-{id_get}-get', 'apiVerificationUrl' => 'http://bitpay.ir/payment/gateway-result-second', - 'callbackUrl' => env('APP_URL') . '/payment/callback', + 'callbackUrl' => env('APP_URL').'/payment/callback', 'api_token' => '066fd-d622e-690a9-be618-ddf02bc6059bbbd67c317bb340d1', 'description' => 'payment using Bitpay', 'currency' => 'R', //Can be R, T (Rial, Toman) @@ -487,5 +487,5 @@ return [ 'toman' => \Shetabit\Multipay\Drivers\Toman\Toman::class, 'bitpay' => \Shetabit\Multipay\Drivers\Bitpay\Bitpay::class, 'minipay' => \Shetabit\Multipay\Drivers\Minipay\Minipay::class, - ] + ], ]; diff --git a/database/migrations/2024_03_29_104255_add_type_to_versions_table.php b/database/migrations/2024_03_29_104255_add_type_to_versions_table.php index b8e9199..6fcf9e5 100644 --- a/database/migrations/2024_03_29_104255_add_type_to_versions_table.php +++ b/database/migrations/2024_03_29_104255_add_type_to_versions_table.php @@ -12,7 +12,7 @@ return new class extends Migration public function up(): void { Schema::table('versions', function (Blueprint $table) { - $table->enum('type',['web','ios','android'])->after('code')->default('web'); + $table->enum('type', ['web', 'ios', 'android'])->after('code')->default('web'); }); } diff --git a/database/migrations/2024_04_04_145848_add_division_to_models.php b/database/migrations/2024_04_04_145848_add_division_to_models.php index 1bf7c7f..81b7414 100644 --- a/database/migrations/2024_04_04_145848_add_division_to_models.php +++ b/database/migrations/2024_04_04_145848_add_division_to_models.php @@ -19,12 +19,10 @@ return new class extends Migration $table->foreignId('division_id')->after('number')->nullable(); }); - Schema::table('parts', function (Blueprint $table) { $table->foreignId('division_id')->after('number')->nullable(); }); - Schema::table('gates', function (Blueprint $table) { $table->foreignId('division_id')->after('number')->nullable(); }); diff --git a/database/migrations/2024_04_11_114231_create_like_sections_table.php b/database/migrations/2024_04_11_114231_create_like_sections_table.php index ae235ca..612a559 100644 --- a/database/migrations/2024_04_11_114231_create_like_sections_table.php +++ b/database/migrations/2024_04_11_114231_create_like_sections_table.php @@ -11,8 +11,7 @@ return new class extends Migration */ public function up(): void { - if(!Schema::hasTable('like_sections')) - { + if (! Schema::hasTable('like_sections')) { Schema::create('like_sections', function (Blueprint $table) { $table->id(); $table->foreignId('user_id'); diff --git a/database/migrations/2024_04_11_124321_create_like_art_table.php b/database/migrations/2024_04_11_124321_create_like_art_table.php index 5d91b9c..05e4e18 100644 --- a/database/migrations/2024_04_11_124321_create_like_art_table.php +++ b/database/migrations/2024_04_11_124321_create_like_art_table.php @@ -11,16 +11,15 @@ return new class extends Migration */ public function up(): void { - if(!Schema::hasTable('like_art')) - { + if (! Schema::hasTable('like_art')) { Schema::create('like_art', function (Blueprint $table) { $table->id(); $table->foreignId('art_id'); $table->foreignId('user_id'); - + $table->timestamps(); }); - + } } diff --git a/database/migrations/2024_04_22_161332_create_notes_table.php b/database/migrations/2024_04_22_161332_create_notes_table.php index f8e6fab..423e92b 100644 --- a/database/migrations/2024_04_22_161332_create_notes_table.php +++ b/database/migrations/2024_04_22_161332_create_notes_table.php @@ -11,7 +11,7 @@ return new class extends Migration */ public function up(): void { - if (!Schema::hasTable('notes')) { + if (! Schema::hasTable('notes')) { Schema::create('notes', function (Blueprint $table) { $table->id(); diff --git a/database/migrations/2024_05_28_171509_create_orders_table.php b/database/migrations/2024_05_28_171509_create_orders_table.php index 11b4207..d896467 100644 --- a/database/migrations/2024_05_28_171509_create_orders_table.php +++ b/database/migrations/2024_05_28_171509_create_orders_table.php @@ -15,7 +15,7 @@ return new class extends Migration $table->id(); $table->foreignId('user_id'); $table->BigInteger('price'); - $table->enum('status' , ['unpaid' , 'paid' , 'canceled']); + $table->enum('status', ['unpaid', 'paid', 'canceled']); $table->string('transaction_id'); $table->timestamps(); }); diff --git a/database/migrations/2024_05_29_180512_create_categories_table.php b/database/migrations/2024_05_29_180512_create_categories_table.php index be9e05f..ca70cf8 100644 --- a/database/migrations/2024_05_29_180512_create_categories_table.php +++ b/database/migrations/2024_05_29_180512_create_categories_table.php @@ -14,7 +14,7 @@ return new class extends Migration Schema::create('categories', function (Blueprint $table) { $table->id(); $table->string('name'); - $table->enum('type',['hagigi','kifari']); + $table->enum('type', ['hagigi', 'kifari']); $table->timestamps(); }); } diff --git a/database/migrations/2024_09_12_152250_create_user_subscribers_table.php b/database/migrations/2024_09_12_152250_create_user_subscribers_table.php index 0162fb5..583c477 100644 --- a/database/migrations/2024_09_12_152250_create_user_subscribers_table.php +++ b/database/migrations/2024_09_12_152250_create_user_subscribers_table.php @@ -15,7 +15,7 @@ return new class extends Migration $table->id(); $table->foreignId('user_id'); $table->foreignId('subscribe_plan_id'); - $table->timestamp('expired_at'); + $table->timestamp('expired_at'); $table->timestamps(); }); } diff --git a/database/migrations/2025_02_22_175910_add_type_to_subscribe_plans_table.php b/database/migrations/2025_02_22_175910_add_type_to_subscribe_plans_table.php index 29f122e..c4332b4 100644 --- a/database/migrations/2025_02_22_175910_add_type_to_subscribe_plans_table.php +++ b/database/migrations/2025_02_22_175910_add_type_to_subscribe_plans_table.php @@ -24,7 +24,7 @@ return new class extends Migration { Schema::table('subscribe_plans', function (Blueprint $table) { $table->string('type')->nullable(); - $table->string('transaction')->nullable(); + $table->string('transaction')->nullable(); }); } }; diff --git a/database/migrations/2025_02_23_210927_add_new_filed_to_user_subscriber_table.php b/database/migrations/2025_02_23_210927_add_new_filed_to_user_subscriber_table.php index 99c9761..c1e00fb 100644 --- a/database/migrations/2025_02_23_210927_add_new_filed_to_user_subscriber_table.php +++ b/database/migrations/2025_02_23_210927_add_new_filed_to_user_subscriber_table.php @@ -11,7 +11,7 @@ return new class extends Migration */ public function up(): void { - Schema::table('user_subscribers', function (Blueprint $table) { + Schema::table('user_subscribers', function (Blueprint $table) { $table->string('subscription_id')->nullable(); $table->string('purchase_token')->nullable(); }); diff --git a/database/migrations/2026_04_24_095201_create_art_judicial_precedent_table.php b/database/migrations/2026_04_24_095201_create_art_judicial_precedent_table.php index 4f7b890..7f8fca6 100644 --- a/database/migrations/2026_04_24_095201_create_art_judicial_precedent_table.php +++ b/database/migrations/2026_04_24_095201_create_art_judicial_precedent_table.php @@ -16,7 +16,7 @@ return new class extends Migration $table->foreignId('art_id')->constrained('art')->onDelete('cascade'); $table->foreignId('judicial_precedent_id')->constrained('judicial_precedents')->onDelete('cascade'); $table->timestamps(); - + $table->unique(['art_id', 'judicial_precedent_id']); }); } diff --git a/database/migrations/2026_06_26_000001_create_bylaw_tables.php b/database/migrations/2026_06_26_000001_create_bylaw_tables.php new file mode 100644 index 0000000..27e885e --- /dev/null +++ b/database/migrations/2026_06_26_000001_create_bylaw_tables.php @@ -0,0 +1,128 @@ +increments('id'); + $table->string('name')->unique(); + $table->enum('authority_type', ['executive', 'judicial', 'legislative', 'administrative', 'other']); + $table->text('description')->nullable(); + $table->timestamps(); + }); + + Schema::create('bylaw_subject_categories', function (Blueprint $table) { + $table->increments('id'); + $table->unsignedInteger('parent_id')->nullable(); + $table->string('name'); + $table->string('slug')->unique(); + $table->integer('sort_order')->default(0); + $table->timestamps(); + + $table->foreign('parent_id')->references('id')->on('bylaw_subject_categories')->nullOnDelete(); + }); + + Schema::create('bylaw_documents', function (Blueprint $table) { + $table->bigIncrements('id'); + $table->string('title', 1000); + $table->unsignedInteger('category_id')->nullable(); + $table->unsignedInteger('approval_authority_id')->nullable(); + $table->date('approval_date')->nullable(); + $table->unsignedInteger('promulgation_authority_id')->nullable(); + $table->date('promulgation_date')->nullable(); + $table->string('promulgation_number', 100)->nullable(); + $table->string('official_gazette_number', 100)->nullable(); + $table->date('official_gazette_date')->nullable(); + $table->date('execution_date')->nullable(); + $table->enum('bylaw_type', ['executive', 'delegated', 'independent']); + $table->enum('global_status', ['valid', 'explicitly_repealed', 'implicitly_repealed', 'annulled', 'expired', 'draft'])->default('valid'); + $table->string('pdf_file_path', 500)->nullable(); + $table->boolean('is_published')->default(true); + $table->text('description')->nullable(); + $table->timestamps(); + + $table->foreign('category_id')->references('id')->on('bylaw_subject_categories')->nullOnDelete(); + $table->foreign('approval_authority_id')->references('id')->on('bylaw_legal_authorities')->nullOnDelete(); + $table->foreign('promulgation_authority_id')->references('id')->on('bylaw_legal_authorities')->nullOnDelete(); + $table->index(['approval_date', 'promulgation_date'], 'idx_bylaw_dates'); + $table->index('global_status', 'idx_bylaw_status'); + }); + + Schema::create('bylaw_node_types', function (Blueprint $table) { + $table->increments('id'); + $table->string('name', 50)->unique(); + $table->integer('hierarchy_level'); + $table->timestamps(); + }); + + Schema::create('bylaw_nodes', function (Blueprint $table) { + $table->bigIncrements('id'); + $table->unsignedBigInteger('document_id'); + $table->unsignedBigInteger('parent_id')->nullable(); + $table->unsignedInteger('node_type_id'); + $table->string('node_identifier', 50)->nullable(); + $table->string('title', 500)->nullable(); + $table->longText('node_content')->nullable(); + $table->integer('sort_order')->default(0); + $table->date('valid_from')->nullable(); + $table->date('valid_to')->nullable(); + $table->enum('node_status', ['valid', 'repealed', 'annulled', 'amended', 'suspended'])->default('valid'); + $table->timestamps(); + + $table->foreign('document_id')->references('id')->on('bylaw_documents')->cascadeOnDelete(); + $table->foreign('parent_id')->references('id')->on('bylaw_nodes')->cascadeOnDelete(); + $table->foreign('node_type_id')->references('id')->on('bylaw_node_types')->restrictOnDelete(); + $table->index(['document_id', 'parent_id'], 'idx_node_tree'); + $table->index(['node_status', 'valid_from', 'valid_to'], 'idx_node_temporal'); + }); + + Schema::table('bylaw_nodes', function (Blueprint $table) { + $table->fullText(['node_content', 'title'], 'ft_idx_content'); + }); + + Schema::create('bylaw_codification_links', function (Blueprint $table) { + $table->bigIncrements('id'); + $table->enum('source_entity_type', ['bylaw_node', 'bylaw_doc', 'law_doc', 'court_verdict', 'advisory_opinion']); + $table->unsignedBigInteger('source_entity_id'); + $table->enum('target_entity_type', ['bylaw_node', 'bylaw_doc', 'law_doc', 'court_verdict', 'advisory_opinion']); + $table->unsignedBigInteger('target_entity_id'); + $table->enum('link_type', ['repeals_explicitly', 'repeals_implicitly', 'annuls_entirely', 'annuls_partially', 'amends', 'adds_to', 'interprets', 'is_executive_bylaw_of']); + $table->date('effective_date')->nullable(); + $table->text('justification')->nullable(); + $table->timestamp('created_at')->useCurrent(); + + $table->unique(['source_entity_type', 'source_entity_id', 'target_entity_type', 'target_entity_id', 'link_type'], 'idx_unique_link'); + $table->index(['target_entity_type', 'target_entity_id'], 'idx_target_search'); + }); + + DB::table('bylaw_node_types')->insertOrIgnore([ + ['id' => 1, 'name' => 'متن کامل آیین‌نامه', 'hierarchy_level' => 1, 'created_at' => now(), 'updated_at' => now()], + ]); + + DB::table('bylaw_subject_categories')->insertOrIgnore([ + ['id' => 9, 'name' => 'آیین نامه ها', 'slug' => 'bylaws', 'sort_order' => 0, 'created_at' => now(), 'updated_at' => now()], + ]); + + DB::statement('SET FOREIGN_KEY_CHECKS=1'); + } + + public function down(): void + { + DB::statement('SET FOREIGN_KEY_CHECKS=0'); + Schema::dropIfExists('bylaw_codification_links'); + Schema::dropIfExists('bylaw_nodes'); + Schema::dropIfExists('bylaw_node_types'); + Schema::dropIfExists('bylaw_documents'); + Schema::dropIfExists('bylaw_subject_categories'); + Schema::dropIfExists('bylaw_legal_authorities'); + DB::statement('SET FOREIGN_KEY_CHECKS=1'); + } +}; diff --git a/resources/views/admin/bylaw-codification-link/create.blade.php b/resources/views/admin/bylaw-codification-link/create.blade.php new file mode 100644 index 0000000..02b1838 --- /dev/null +++ b/resources/views/admin/bylaw-codification-link/create.blade.php @@ -0,0 +1,11 @@ +@extends('admin.layouts.app') +@section('content') +
@csrf + + + + + + + +
@endsection diff --git a/resources/views/admin/bylaw-codification-link/index.blade.php b/resources/views/admin/bylaw-codification-link/index.blade.php new file mode 100644 index 0000000..40c9421 --- /dev/null +++ b/resources/views/admin/bylaw-codification-link/index.blade.php @@ -0,0 +1,3 @@ +@extends('admin.layouts.app') +@section('content') +
افزودن@foreach($items as $item)@endforeach
منبعهدفنوععملیات
{{ $item->source_entity_type }}#{{ $item->source_entity_id }}{{ $item->target_entity_type }}#{{ $item->target_entity_id }}{{ $item->link_type }}ویرایش
{{ $items->links() }}
@endsection diff --git a/resources/views/admin/bylaw-codification-link/update.blade.php b/resources/views/admin/bylaw-codification-link/update.blade.php new file mode 100644 index 0000000..f98eef5 --- /dev/null +++ b/resources/views/admin/bylaw-codification-link/update.blade.php @@ -0,0 +1,11 @@ +@extends('admin.layouts.app') +@section('content') +
@csrf @method('PUT') + + + + + + + +
@endsection diff --git a/resources/views/admin/bylaw-document/create.blade.php b/resources/views/admin/bylaw-document/create.blade.php new file mode 100644 index 0000000..760c4fe --- /dev/null +++ b/resources/views/admin/bylaw-document/create.blade.php @@ -0,0 +1,15 @@ +@extends('admin.layouts.app') +@section('content') +
@csrf + + + + + + + + + + + +
@endsection diff --git a/resources/views/admin/bylaw-document/index.blade.php b/resources/views/admin/bylaw-document/index.blade.php new file mode 100644 index 0000000..a6f0475 --- /dev/null +++ b/resources/views/admin/bylaw-document/index.blade.php @@ -0,0 +1,4 @@ +@extends('admin.layouts.app') +@section('content') +
افزودن +@foreach($items as $item)@endforeach
عنواننوعوضعیتعملیات
{{ $item->title }}{{ $item->bylaw_type }}{{ $item->global_status }}ویرایش
{{ $items->links() }}
@endsection diff --git a/resources/views/admin/bylaw-document/update.blade.php b/resources/views/admin/bylaw-document/update.blade.php new file mode 100644 index 0000000..0832bbe --- /dev/null +++ b/resources/views/admin/bylaw-document/update.blade.php @@ -0,0 +1,15 @@ +@extends('admin.layouts.app') +@section('content') +
@csrf @method('PUT') + + + + + + + + + + + +
@endsection diff --git a/resources/views/admin/bylaw-legal-authority/create.blade.php b/resources/views/admin/bylaw-legal-authority/create.blade.php new file mode 100644 index 0000000..b750d6b --- /dev/null +++ b/resources/views/admin/bylaw-legal-authority/create.blade.php @@ -0,0 +1,9 @@ +@extends('admin.layouts.app') +@section('content') +
@csrf + + + + +
+@endsection diff --git a/resources/views/admin/bylaw-legal-authority/index.blade.php b/resources/views/admin/bylaw-legal-authority/index.blade.php new file mode 100644 index 0000000..af70d8f --- /dev/null +++ b/resources/views/admin/bylaw-legal-authority/index.blade.php @@ -0,0 +1,8 @@ +@extends('admin.layouts.app') +@section('content') +
+افزودن +@foreach($items as $item)@endforeach
نامنوععملیات
{{ $item->name }}{{ $item->authority_type }}ویرایش
+{{ $items->links() }} +
+@endsection diff --git a/resources/views/admin/bylaw-legal-authority/update.blade.php b/resources/views/admin/bylaw-legal-authority/update.blade.php new file mode 100644 index 0000000..f28c47f --- /dev/null +++ b/resources/views/admin/bylaw-legal-authority/update.blade.php @@ -0,0 +1,9 @@ +@extends('admin.layouts.app') +@section('content') +
@csrf @method('PUT') + + + + +
+@endsection diff --git a/resources/views/admin/bylaw-node-type/create.blade.php b/resources/views/admin/bylaw-node-type/create.blade.php new file mode 100644 index 0000000..ec51a6f --- /dev/null +++ b/resources/views/admin/bylaw-node-type/create.blade.php @@ -0,0 +1,6 @@ +@extends('admin.layouts.app') +@section('content') +
@csrf + + +
@endsection diff --git a/resources/views/admin/bylaw-node-type/index.blade.php b/resources/views/admin/bylaw-node-type/index.blade.php new file mode 100644 index 0000000..9ab11f9 --- /dev/null +++ b/resources/views/admin/bylaw-node-type/index.blade.php @@ -0,0 +1,3 @@ +@extends('admin.layouts.app') +@section('content') +
افزودن@foreach($items as $item)@endforeach
نامسطحعملیات
{{ $item->name }}{{ $item->hierarchy_level }}ویرایش
{{ $items->links() }}
@endsection diff --git a/resources/views/admin/bylaw-node-type/update.blade.php b/resources/views/admin/bylaw-node-type/update.blade.php new file mode 100644 index 0000000..e5208bd --- /dev/null +++ b/resources/views/admin/bylaw-node-type/update.blade.php @@ -0,0 +1,6 @@ +@extends('admin.layouts.app') +@section('content') +
@csrf @method('PUT') + + +
@endsection diff --git a/resources/views/admin/bylaw-node/create.blade.php b/resources/views/admin/bylaw-node/create.blade.php new file mode 100644 index 0000000..91d255f --- /dev/null +++ b/resources/views/admin/bylaw-node/create.blade.php @@ -0,0 +1,13 @@ +@extends('admin.layouts.app') +@section('content') +
@csrf + + + + + + + + + +
@endsection diff --git a/resources/views/admin/bylaw-node/index.blade.php b/resources/views/admin/bylaw-node/index.blade.php new file mode 100644 index 0000000..5e57d29 --- /dev/null +++ b/resources/views/admin/bylaw-node/index.blade.php @@ -0,0 +1,3 @@ +@extends('admin.layouts.app') +@section('content') +
افزودن@foreach($items as $item)@endforeach
سندنوععنوانعملیات
{{ $item->document?->title }}{{ $item->type?->name }}{{ $item->title }}ویرایش
{{ $items->links() }}
@endsection diff --git a/resources/views/admin/bylaw-node/update.blade.php b/resources/views/admin/bylaw-node/update.blade.php new file mode 100644 index 0000000..0db53c3 --- /dev/null +++ b/resources/views/admin/bylaw-node/update.blade.php @@ -0,0 +1,13 @@ +@extends('admin.layouts.app') +@section('content') +
@csrf @method('PUT') + + + + + + + + + +
@endsection diff --git a/resources/views/admin/bylaw-subject-category/create.blade.php b/resources/views/admin/bylaw-subject-category/create.blade.php new file mode 100644 index 0000000..49adf5b --- /dev/null +++ b/resources/views/admin/bylaw-subject-category/create.blade.php @@ -0,0 +1,8 @@ +@extends('admin.layouts.app') +@section('content') +
@csrf + + + + +
@endsection diff --git a/resources/views/admin/bylaw-subject-category/index.blade.php b/resources/views/admin/bylaw-subject-category/index.blade.php new file mode 100644 index 0000000..6f66092 --- /dev/null +++ b/resources/views/admin/bylaw-subject-category/index.blade.php @@ -0,0 +1,4 @@ +@extends('admin.layouts.app') +@section('content') +
افزودن +@foreach($items as $item)@endforeach
ناماسلاگعملیات
{{ $item->name }}{{ $item->slug }}ویرایش
{{ $items->links() }}
@endsection diff --git a/resources/views/admin/bylaw-subject-category/update.blade.php b/resources/views/admin/bylaw-subject-category/update.blade.php new file mode 100644 index 0000000..1d7897a --- /dev/null +++ b/resources/views/admin/bylaw-subject-category/update.blade.php @@ -0,0 +1,8 @@ +@extends('admin.layouts.app') +@section('content') +
@csrf @method('PUT') + + + + +
@endsection diff --git a/resources/views/admin/partial/menu.blade.php b/resources/views/admin/partial/menu.blade.php index 046cb6b..1ff1dee 100644 --- a/resources/views/admin/partial/menu.blade.php +++ b/resources/views/admin/partial/menu.blade.php @@ -231,6 +231,20 @@ +
  • + + + آیین‌نامه‌ها + + +
  • +
  • diff --git a/routes/api.php b/routes/api.php index f181933..9ba1a90 100644 --- a/routes/api.php +++ b/routes/api.php @@ -1,6 +1,5 @@ middleware('auth:sanctum')->group(function () { Route::get('home', [HomeController::class, 'index']); Route::get('notifications', [NotificationController::class, 'index']); Route::get('art', [ArtController::class, 'index']); - Route::get('categories',[CategoriesController::class, 'index']); + Route::get('categories', [CategoriesController::class, 'index']); Route::post('art/search', [ArtController::class, 'search']); - Route::post('fast-search',[ArtController::class,'fash_search']); + Route::post('fast-search', [ArtController::class, 'fash_search']); Route::post('art/note', [NoteController::class, 'create']); Route::put('art/note/{id}', [NoteController::class, 'update']); Route::delete('art/note/{id}', [NoteController::class, 'destroy']); @@ -59,14 +59,14 @@ Route::prefix('v1')->middleware('auth:sanctum')->group(function () { Route::post('subscribe-plan-user-new', [SubscribePlanController::class, 'subscribe_new']); Route::post('subscribe-plan-user-myket', [SubscribePlanController::class, 'subscribeMyket']); Route::get('subscribe-plan-current', [SubscribePlanController::class, 'current']); - Route::post('pay',[PayController::class, 'pay']); + Route::post('pay', [PayController::class, 'pay']); - Route::get('folders',[FolderController::class,'index']); - Route::post('folders',[FolderController::class,'create']); - Route::post('assign_folder',[FolderController::class,'assign']); - Route::get('folders/{id}',[FolderController::class,'folder']); - Route::delete('folders/{id}',[FolderController::class,'delete_folder']); - Route::delete('folders/{id}/art/{art_id}',[FolderController::class,'delete_art']); + Route::get('folders', [FolderController::class, 'index']); + Route::post('folders', [FolderController::class, 'create']); + Route::post('assign_folder', [FolderController::class, 'assign']); + Route::get('folders/{id}', [FolderController::class, 'folder']); + Route::delete('folders/{id}', [FolderController::class, 'delete_folder']); + Route::delete('folders/{id}/art/{art_id}', [FolderController::class, 'delete_art']); - Route::post('suggestions',[SuggestionController::class,'index']); + Route::post('suggestions', [SuggestionController::class, 'index']); }); diff --git a/routes/web.php b/routes/web.php index b305a2a..af93bab 100644 --- a/routes/web.php +++ b/routes/web.php @@ -3,17 +3,22 @@ use App\Http\Controllers\Admin\ArtController; use App\Http\Controllers\Admin\BookController; use App\Http\Controllers\Admin\BranchController; -use App\Http\Controllers\Admin\CategoriesController; +use App\Http\Controllers\Admin\BylawCodificationLinkController; +use App\Http\Controllers\Admin\BylawDocumentController; +use App\Http\Controllers\Admin\BylawLegalAuthorityController; +use App\Http\Controllers\Admin\BylawNodeController; +use App\Http\Controllers\Admin\BylawNodeTypeController; +use App\Http\Controllers\Admin\BylawSubjectCategoryController; use App\Http\Controllers\Admin\CategoryController; use App\Http\Controllers\Admin\ChapterController; use App\Http\Controllers\Admin\DivisionController; use App\Http\Controllers\Admin\GateController; use App\Http\Controllers\Admin\HomeController; -use App\Http\Controllers\Admin\JudicialPrecedentController; use App\Http\Controllers\Admin\JudicialPrecedentCategoryController; +use App\Http\Controllers\Admin\JudicialPrecedentController; use App\Http\Controllers\Admin\LawController; -use App\Http\Controllers\Admin\LegalOpinionController; use App\Http\Controllers\Admin\LegalOpinionCategoryController; +use App\Http\Controllers\Admin\LegalOpinionController; use App\Http\Controllers\Admin\NotificationController; use App\Http\Controllers\Admin\PartController; use App\Http\Controllers\Admin\SectionController; @@ -26,10 +31,10 @@ use App\Http\Controllers\api\PayController; use Illuminate\Support\Facades\Route; Route::get('payment/callback', [PayController::class, 'callback']); -Route::middleware(['auth',config('jetstream.auth_session')])->group(function () { +Route::middleware(['auth', config('jetstream.auth_session')])->group(function () { Route::get('dashboard', [HomeController::class, 'index'])->name('dashboard'); - Route::resource('categories',CategoryController::class); - Route::resource('versions',VersionController::class); + Route::resource('categories', CategoryController::class); + Route::resource('versions', VersionController::class); Route::resource('users', UsersController::class); Route::resource('law', LawController::class); Route::resource('art', ArtController::class); @@ -47,5 +52,11 @@ Route::middleware(['auth',config('jetstream.auth_session')])->group(function () Route::resource('judicial-precedent-category', JudicialPrecedentCategoryController::class); Route::resource('legal-opinion', LegalOpinionController::class); Route::resource('legal-opinion-category', LegalOpinionCategoryController::class); - Route::get('suggestions',[SuggestionController::class,'index'])->name('suggestions.index'); + Route::resource('bylaw-legal-authority', BylawLegalAuthorityController::class); + Route::resource('bylaw-subject-category', BylawSubjectCategoryController::class); + Route::resource('bylaw-document', BylawDocumentController::class); + Route::resource('bylaw-node-type', BylawNodeTypeController::class); + Route::resource('bylaw-node', BylawNodeController::class); + Route::resource('bylaw-codification-link', BylawCodificationLinkController::class); + Route::get('suggestions', [SuggestionController::class, 'index'])->name('suggestions.index'); });