save course from disk begin
This commit is contained in:
@@ -18,7 +18,7 @@ class AUKController extends Controller
|
||||
{
|
||||
$project_id = $request->session()->get('project_id');
|
||||
$project = Project::find($project_id);
|
||||
$top_auks = $project->auks()->where('parent_id',0)->get();
|
||||
$top_auks = $project->auks()->where('parent_id', 0)->get();
|
||||
return view('auks.list', ['project' => $project, 'top_auks' => $top_auks]);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ class AUKController extends Controller
|
||||
{
|
||||
$project_id = $request->session()->get('project_id');
|
||||
$project = Project::find($project_id);
|
||||
$top_auks = $project->auks()->where('parent_id',0)->get();
|
||||
$top_auks = $project->auks()->where('parent_id', 0)->get();
|
||||
return view('auks.create', ['project' => $project, 'top_auks' => $top_auks]);
|
||||
}
|
||||
|
||||
@@ -80,11 +80,11 @@ class AUKController extends Controller
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(Request $request,$id)
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
$project_id = $request->session()->get('project_id');
|
||||
$project = Project::find($project_id);
|
||||
$top_auks = $project->auks()->where('parent_id',0)->get();
|
||||
$top_auks = $project->auks()->where('parent_id', 0)->get();
|
||||
$auk = AUK::find($id);
|
||||
return view('auks.edit', ['project' => $project, 'top_auks' => $top_auks, 'auk' => $auk]);
|
||||
}
|
||||
@@ -126,4 +126,72 @@ class AUKController extends Controller
|
||||
AUK::findOrFail($id)->delete();
|
||||
return redirect()->route('auks.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show form to to load AUKs from file system
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function scan(Request $request)
|
||||
{
|
||||
$project_id = $request->session()->get('project_id');
|
||||
$project = Project::find($project_id);
|
||||
|
||||
|
||||
$auks = array();
|
||||
$MMC_PATH = $project->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;
|
||||
}
|
||||
}
|
||||
}
|
||||
array_push($auks,$tmp_array);
|
||||
}
|
||||
}
|
||||
}
|
||||
return view('auks.scan', ['project' => $project, 'auks' => $auks]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load AUKs from file system
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function load(Request $request)
|
||||
{
|
||||
$project_id = $request->session()->get('project_id');
|
||||
$request->validate([
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'number' => ['required', 'integer'],
|
||||
'parent_id' => ['required', 'integer'],
|
||||
]);
|
||||
|
||||
// $user =
|
||||
AUK::create([
|
||||
'project_id' => $project_id,
|
||||
'name' => $request->name,
|
||||
'number' => $request->number,
|
||||
'parent_id' => $request->parent_id,
|
||||
]);
|
||||
|
||||
return redirect(route('auks.index'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -183,6 +183,6 @@ class MMCController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
return view('mmc.scan', ['project' => $project,'MMC' => $MMC]);
|
||||
return view('mmc.scan', ['project' => $project, 'MMC' => $MMC]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user