Updated VolumController.php
This commit is contained in:
@@ -57,8 +57,8 @@ class VolumController extends Controller
|
||||
$gate_id = $request->gate_id;
|
||||
|
||||
$perPage = $request->per_page ?? 10;
|
||||
|
||||
if ($bookId) {
|
||||
// ترتیب درست اعمال شد
|
||||
$book = Book::with(['divisions', 'sections', 'chapters', 'parts', 'gates', 'branchs', 'art'])
|
||||
->find($bookId);
|
||||
|
||||
@@ -96,7 +96,7 @@ class VolumController extends Controller
|
||||
}
|
||||
|
||||
if ($division_id) {
|
||||
$division = Division::with(['sections', 'chapters', 'parts', 'gates', 'branchs', 'art'])
|
||||
$division = Division::with(['sections', 'chapters', 'parts', 'gate', 'branch', 'art'])
|
||||
->find($division_id);
|
||||
|
||||
if (! $division) {
|
||||
@@ -105,7 +105,7 @@ class VolumController extends Controller
|
||||
|
||||
$data = [];
|
||||
$foundRelation = false;
|
||||
foreach (['sections', 'chapters', 'parts', 'gates', 'branchs', 'art'] as $relation) {
|
||||
foreach (['sections', 'chapters', 'parts', 'gate', 'branch', 'art'] as $relation) {
|
||||
if ($division->{$relation}->count() > 0) {
|
||||
$foundRelation = true;
|
||||
$items = $division->{$relation}()->paginate($perPage);
|
||||
@@ -130,7 +130,7 @@ class VolumController extends Controller
|
||||
}
|
||||
|
||||
if ($section_id) {
|
||||
$section = Section::with(['chapters', 'parts', 'gates', 'branchs', 'art'])
|
||||
$section = Section::with(['chapters', 'parts', 'gate', 'branch', 'art'])
|
||||
->find($section_id);
|
||||
|
||||
if (! $section) {
|
||||
@@ -139,7 +139,7 @@ class VolumController extends Controller
|
||||
|
||||
$data = [];
|
||||
$foundRelation = false;
|
||||
foreach (['chapters', 'parts', 'gates', 'branchs', 'art'] as $relation) {
|
||||
foreach (['chapters', 'parts', 'gate', 'branch', 'art'] as $relation) {
|
||||
if ($section->{$relation}->count() > 0) {
|
||||
$foundRelation = true;
|
||||
$items = $section->{$relation}()->paginate($perPage);
|
||||
@@ -197,7 +197,7 @@ class VolumController extends Controller
|
||||
}
|
||||
|
||||
if ($chapter_id) {
|
||||
$chapter = Chapter::with(['parts', 'gates', 'branchs', 'art'])
|
||||
$chapter = Chapter::with(['parts', 'gate', 'branch', 'art'])
|
||||
->find($chapter_id);
|
||||
|
||||
if (! $chapter) {
|
||||
@@ -206,7 +206,7 @@ class VolumController extends Controller
|
||||
|
||||
$data = [];
|
||||
$foundRelation = false;
|
||||
foreach (['parts', 'gates', 'branchs', 'art'] as $relation) {
|
||||
foreach (['parts', 'gate', 'branch', 'art'] as $relation) {
|
||||
if ($chapter->{$relation}->count() > 0) {
|
||||
$foundRelation = true;
|
||||
$items = $chapter->{$relation}()->paginate($perPage);
|
||||
@@ -231,7 +231,7 @@ class VolumController extends Controller
|
||||
}
|
||||
|
||||
if ($part_id) {
|
||||
$part = Part::with(['gates', 'branchs', 'art'])
|
||||
$part = Part::with(['gate', 'branch', 'art'])
|
||||
->find($part_id);
|
||||
|
||||
if (! $part) {
|
||||
@@ -240,7 +240,7 @@ class VolumController extends Controller
|
||||
|
||||
$data = [];
|
||||
$foundRelation = false;
|
||||
foreach (['gates', 'branchs', 'art'] as $relation) {
|
||||
foreach (['gate', 'branch', 'art'] as $relation) {
|
||||
if ($part->{$relation}->count() > 0) {
|
||||
$foundRelation = true;
|
||||
$items = $part->{$relation}()->paginate($perPage);
|
||||
@@ -265,7 +265,7 @@ class VolumController extends Controller
|
||||
}
|
||||
|
||||
if ($gate_id) {
|
||||
$gate = Gate::with(['branchs', 'art'])
|
||||
$gate = Gate::with(['branch', 'art'])
|
||||
->find($gate_id);
|
||||
|
||||
if (! $gate) {
|
||||
@@ -274,7 +274,7 @@ class VolumController extends Controller
|
||||
|
||||
$data = [];
|
||||
$foundRelation = false;
|
||||
foreach (['branchs', 'art'] as $relation) {
|
||||
foreach (['branch', 'art'] as $relation) {
|
||||
if ($gate->{$relation}->count() > 0) {
|
||||
$foundRelation = true;
|
||||
$items = $gate->{$relation}()->paginate($perPage);
|
||||
@@ -550,7 +550,7 @@ class VolumController extends Controller
|
||||
return $this->success([], 'Law not found');
|
||||
}
|
||||
|
||||
$data = $this->checkRelations($law, ['volums', 'book', 'divisions', 'sections', 'chapters', 'parts', 'gates', 'branchs', 'arts'], $perPage);
|
||||
$data = $this->checkRelations($law, ['volums', 'divisions', 'sections', 'chapters', 'parts', 'gates', 'branchs', 'arts'], $perPage);
|
||||
if ($data) {
|
||||
return $this->success($data, 'Success');
|
||||
}
|
||||
@@ -587,12 +587,12 @@ class VolumController extends Controller
|
||||
}
|
||||
|
||||
if ($divisionId) {
|
||||
$division = Division::with(['sections', 'chapters', 'parts', 'gates', 'branchs', 'art'])->find($divisionId);
|
||||
$division = Division::with(['chapters', 'parts', 'gates', 'branchs', 'art'])->find($divisionId);
|
||||
if (! $division) {
|
||||
return $this->success([], 'Division not found');
|
||||
}
|
||||
|
||||
$data = $this->checkRelations($division, ['sections', 'chapters', 'parts', 'gates', 'branchs', 'art'], $perPage);
|
||||
$data = $this->checkRelations($division, ['chapters', 'parts', 'gates', 'branchs', 'art'], $perPage);
|
||||
if ($data) {
|
||||
return $this->success($data, 'Success');
|
||||
}
|
||||
@@ -615,12 +615,12 @@ class VolumController extends Controller
|
||||
}
|
||||
|
||||
if ($chapterId) {
|
||||
$chapter = Chapter::with(['parts', 'gates', 'branchs', 'art'])->find($chapterId);
|
||||
$chapter = Chapter::with(['parts', 'gate', 'art'])->find($chapterId);
|
||||
if (! $chapter) {
|
||||
return $this->success([], 'Chapter not found');
|
||||
}
|
||||
|
||||
$data = $this->checkRelations($chapter, ['parts', 'gates', 'branchs', 'art'], $perPage);
|
||||
$data = $this->checkRelations($chapter, ['parts', 'gate', 'art'], $perPage);
|
||||
if ($data) {
|
||||
return $this->success($data, 'Success');
|
||||
}
|
||||
@@ -629,12 +629,12 @@ class VolumController extends Controller
|
||||
}
|
||||
|
||||
if ($partId) {
|
||||
$part = Part::with(['gates', 'branchs', 'art'])->find($partId);
|
||||
$part = Part::with(['gates', 'art'])->find($partId);
|
||||
if (! $part) {
|
||||
return $this->success([], 'Part not found');
|
||||
}
|
||||
|
||||
$data = $this->checkRelations($part, ['gates', 'branchs', 'art'], $perPage);
|
||||
$data = $this->checkRelations($part, ['gates', 'art'], $perPage);
|
||||
if ($data) {
|
||||
return $this->success($data, 'Success');
|
||||
}
|
||||
@@ -643,12 +643,12 @@ class VolumController extends Controller
|
||||
}
|
||||
|
||||
if ($gateId) {
|
||||
$gate = Gate::with(['branchs', 'art'])->find($gateId);
|
||||
$gate = Gate::with(['art'])->find($gateId);
|
||||
if (! $gate) {
|
||||
return $this->success([], 'Gate not found');
|
||||
}
|
||||
|
||||
$data = $this->checkRelations($gate, ['branchs', 'art'], $perPage);
|
||||
$data = $this->checkRelations($gate, ['art'], $perPage);
|
||||
if ($data) {
|
||||
return $this->success($data, 'Success');
|
||||
}
|
||||
@@ -657,12 +657,12 @@ class VolumController extends Controller
|
||||
}
|
||||
|
||||
if ($branchId) {
|
||||
$branch = Branch::with(['art'])->find($branchId);
|
||||
$branch = Branch::with(['chapters', 'gates', 'art'])->find($branchId);
|
||||
if (! $branch) {
|
||||
return $this->success([], 'Branch not found');
|
||||
}
|
||||
|
||||
$data = $this->checkRelations($branch, ['art'], $perPage);
|
||||
$data = $this->checkRelations($branch, ['chapters', 'gates', 'art'], $perPage);
|
||||
if ($data) {
|
||||
return $this->success($data, 'Success');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user