Continue MMC

This commit is contained in:
Александр Бабкин
2022-07-14 11:01:44 +03:00
parent 30950a120e
commit 97bacd4423
10 changed files with 158 additions and 24 deletions

View File

@@ -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++;
}

View File

@@ -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]);
}
/**

View File

@@ -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');
}
}

View File

@@ -16,5 +16,10 @@ class MMC extends Model
'size',
'mtime',
'atime',
];
];
public function auks()
{
return $this->belongsToMany(AUK::class);
}
}