diff --git a/app/Http/Controllers/AUKController.php b/app/Http/Controllers/AUKController.php
index b5e7215..3675682 100644
--- a/app/Http/Controllers/AUKController.php
+++ b/app/Http/Controllers/AUKController.php
@@ -147,26 +147,29 @@ class AUKController extends Controller
$auks = array();
$MMC_PATH = $project->mmc_path;
- $mmc_dir = scandir($MMC_PATH);
+ if(is_dir($MMC_PATH))
+ {
+ $mmc_dir = scandir($MMC_PATH);
- foreach ($mmc_dir as $entry) {
- $course_path = $MMC_PATH . '/' . $entry;
- if (is_dir($course_path)) {
- if (intval($entry) > 0 && intval($entry) < 99) {
- $tmp_array = array();
- $tmp_array['auk_name'] = "АУК " . $entry;
- $tmp_array['auk_path'] = $entry;
- $tmp_array['image_dir'] = "";
- $mmc_course_dir = scandir($course_path);
- foreach ($mmc_course_dir as $course_entry) {
- if (strcasecmp($course_entry, 'images') == 0) {
- $course_image_path = $course_path . '/' . $course_entry;
- if (is_dir($course_image_path)) {
- $tmp_array['image_dir'] = $course_entry;
+ foreach ($mmc_dir as $entry) {
+ $course_path = $MMC_PATH . '/' . $entry;
+ if (is_dir($course_path)) {
+ if (intval($entry) > 0 && intval($entry) < 99) {
+ $tmp_array = array();
+ $tmp_array['auk_name'] = "АУК " . $entry;
+ $tmp_array['auk_path'] = $entry;
+ $tmp_array['image_dir'] = "";
+ $mmc_course_dir = scandir($course_path);
+ foreach ($mmc_course_dir as $course_entry) {
+ if (strcasecmp($course_entry, 'images') == 0) {
+ $course_image_path = $course_path . '/' . $course_entry;
+ if (is_dir($course_image_path)) {
+ $tmp_array['image_dir'] = $course_entry;
+ }
}
}
+ array_push($auks, $tmp_array);
}
- array_push($auks, $tmp_array);
}
}
}
@@ -199,7 +202,7 @@ class AUKController extends Controller
'auk_name' => $auk_name,
'auk_path' => $auk_path,
'image_dir' => $image_dir,
- 'parent_id' => null,
+ 'parent_id' => 0,
]);
$i++;
}
diff --git a/app/Http/Controllers/MMCController.php b/app/Http/Controllers/MMCController.php
index a10ae59..acdf435 100644
--- a/app/Http/Controllers/MMCController.php
+++ b/app/Http/Controllers/MMCController.php
@@ -4,6 +4,9 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Project;
+use App\Models\AUK;
+use App\Models\Document;
+
class MMCController extends Controller
{
@@ -17,7 +20,12 @@ class MMCController extends Controller
{
$project_id = $request->session()->get('project_id');
$project = Project::find($project_id);
- return view('mmc.list', ['project' => $project]);
+ $top_auks = $project->auks()->where('parent_id', 0)->get()->sortBy('auk_name');
+ if(count($top_auks))
+ {
+ $mmc = $top_auks[0]->mmcs;
+ }
+ return view('mmc.list', ['project' => $project, 'top_auks' => $top_auks]);
}
/**
diff --git a/app/Models/AUK.php b/app/Models/AUK.php
index 340faff..4f26512 100644
--- a/app/Models/AUK.php
+++ b/app/Models/AUK.php
@@ -23,5 +23,11 @@ class AUK extends Model
{
return $this->hasMany('App\Models\AUK','parent_id','id');
}
+
+ public function mmcs()
+ {
+ return $this->belongsToMany(MMC::class,'auk_mmc','auk_id','mmc_id');
+ }
+
}
diff --git a/app/Models/MMC.php b/app/Models/MMC.php
index e7cf427..71cd1d2 100644
--- a/app/Models/MMC.php
+++ b/app/Models/MMC.php
@@ -16,5 +16,10 @@ class MMC extends Model
'size',
'mtime',
'atime',
- ];
+ ];
+
+ public function auks()
+ {
+ return $this->belongsToMany(AUK::class);
+ }
}
diff --git a/database/migrations/2022_07_14_081130_create_auk_mmc_table.php b/database/migrations/2022_07_14_081130_create_auk_mmc_table.php
new file mode 100644
index 0000000..65c0a80
--- /dev/null
+++ b/database/migrations/2022_07_14_081130_create_auk_mmc_table.php
@@ -0,0 +1,33 @@
+id();
+ $table->integer('auk_id')->unsigned()->references('id')->on('auks');
+ $table->integer('mmc_id')->unsigned()->references('id')->on('mmcs');
+ $table->timestamps();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::dropIfExists('auk_mmc');
+ }
+}
diff --git a/database/seeders/ProjectTableSeeder.php b/database/seeders/ProjectTableSeeder.php
index 7db408c..1364b64 100644
--- a/database/seeders/ProjectTableSeeder.php
+++ b/database/seeders/ProjectTableSeeder.php
@@ -17,7 +17,7 @@ class ProjectTableSeeder extends Seeder
DB::table('projects')->insert([
'name' => 'Ил-76МД90А',
'description' => 'АОС Ил-76МД90А',
- 'mmc_path' => '/Docs/Project/643 Россия/IL-76MD-90А_ru/2_MMC',
+ 'mmc_path' => '/home/shurick/tmp/mmc',
]);
}
diff --git a/resources/views/auks/scan.blade.php b/resources/views/auks/scan.blade.php
index 76137af..b086a8f 100644
--- a/resources/views/auks/scan.blade.php
+++ b/resources/views/auks/scan.blade.php
@@ -38,7 +38,7 @@
@empty
- | No Documents!
+ | No AUKs!
|
@endforelse
diff --git a/resources/views/mmc/list.blade.php b/resources/views/mmc/list.blade.php
index c9e7142..5bdd542 100644
--- a/resources/views/mmc/list.blade.php
+++ b/resources/views/mmc/list.blade.php
@@ -13,7 +13,7 @@
-
+ {{--
-
- TODO: MMC table
+
--}}
+ {{--
+
+
+
+
+
+ @foreach ($top_auks as $auks)
+
+ @if (count($auks->childs))
+ @include('mmc.optionChild', [
+ 'childs' => $auks->childs,
+ 'level' => 1,
+ ])
+ @endif
+ @endforeach
+
+
+
--}}
+
+
Выберите АУК:
+
+ | AUK Title |
+ MMC |
+
+ @forelse ($top_auks as $top_auk)
+
+ | {{ $top_auk->auk_name }} |
+
+
+ {{-- @forelse ($top_auk->mmcs as $mmc)
+
+ | {{ $mmc->filename }} |
+
+
+ @empty
+
+ | No MMC |
+
+
+ @endforelse --}}
+
+ |
+
+ @if (count($top_auk->childs))
+ @include('mmc.tableAukChild', [
+ 'childs' => $top_auk->childs,
+ 'level' => 1,
+ ])
+ @endif
+ @empty
+
+ | No AUK |
+
+ @endforelse
+ {{--
--}}
diff --git a/resources/views/mmc/optionChild.blade.php b/resources/views/mmc/optionChild.blade.php
new file mode 100644
index 0000000..8562d01
--- /dev/null
+++ b/resources/views/mmc/optionChild.blade.php
@@ -0,0 +1,10 @@
+@foreach ($childs as $child)
+
+ @if (count($child->childs))
+ @include('mmc.optionChild', [
+ 'childs' => $child->childs,
+ 'level' => $level + 1,
+ ])
+ @endif
+@endforeach
diff --git a/resources/views/mmc/tableAukChild.blade.php b/resources/views/mmc/tableAukChild.blade.php
new file mode 100644
index 0000000..a8fda72
--- /dev/null
+++ b/resources/views/mmc/tableAukChild.blade.php
@@ -0,0 +1,13 @@
+@foreach ($childs as $child)
+
+ |
+ {{ str_pad('', $level, '-') . ' ' . $child->auk_name }}
+ |
+
+ @if (count($child->childs))
+ @include('mmc.tableAukChild', [
+ 'childs' => $top_auk->childs,
+ 'level' => $level + 1,
+ ])
+ @endif
+@endforeach