show MMC alpha ready

This commit is contained in:
Александр Бабкин
2022-07-15 12:41:52 +03:00
parent cce02034f4
commit 518b072533
6 changed files with 246 additions and 161 deletions

View File

@@ -7,6 +7,8 @@ use App\Models\Project;
use App\Models\AUK;
use App\Models\MMC;
use Illuminate\Support\Facades\Log;
use Illuminate\Http\Response;
@@ -75,23 +77,52 @@ class MMCController extends Controller
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show(Request $request, $id)
public function show(Request $request, $auk_id, $mmc_id)
{
$project_id = $request->session()->get('project_id');
$project = Project::find($project_id);
$mmc = MMC::find($id);
$auk = $mmc->auks()->first();
$auk = AUK::find($auk_id);
$MMC = $auk->mmcs;
$current_mmc = '';
if ($mmc_id == 0) {
$current_mmc = $MMC->first();
} else {
$current_mmc = MMC::find($mmc_id);
}
return view('mmc.show', ['project' => $project, 'auk' => $auk, 'current_mmc' => $current_mmc]);
}
/**
* Display the specified resource.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function getimage(Request $request, $auk_id, $mmc_id)
{
$project_id = $request->session()->get('project_id');
$project = Project::find($project_id);
$auk = AUK::find($auk_id);
$mmc = MMC::find($mmc_id);
$filePath = $project->mmc_path . '/' . $auk->auk_path . '/' . $auk->image_dir . '/' . $mmc->filename;
if(strcasecmp(substr($mmc->filename, -3, 3), 'svg') == 0 )
{
// $svg = file_get_contents($filePath);
// return response()->header('Content-Type', 'image/svg+xml')->file($filePath);
// return response()->file($filePath);
if (strcasecmp(substr($mmc->filename, -3, 3), 'svg') == 0) {
// $svg = readfile($filePath);
// $response = Response::make($svg, 200);
// $response->header('Content-Type', 'image/svg+xml');
// $response->header('Content-disposition', 'attachment; filename="' . $mmc->filename . '"');
// return $response;
// return response($svg)->header('Content-Type', 'image/svg+xml');
// return response()->header('filename', $mmc->filename)->file($filePath);
// file($filePath)->header('Content-Type', 'image/svg+xml');
}
else
{
return view('components.svg',['project'=>$project, 'auk' => $auk, 'mmc' => $mmc]);
} else {
return response()->file($filePath);
}
}
@@ -202,7 +233,7 @@ class MMCController extends Controller
while ($request->input('filename_' . $i) !== null) {
$filename = $request->input('filename_' . $i);
$size = $request->input('size_' . $i);
$mtime= $request->input('mtime_' . $i);
$mtime = $request->input('mtime_' . $i);
// Log::alert("filename \"" . $filename . "\"");
// Log::alert("size \"" . $size . "\"");
// Log::alert("mtime \"" . $mtime . "\"");