Refactor image handling in PrintPatternController and TemplatesController to use MinIO for improved storage management
This commit is contained in:
@@ -5,6 +5,7 @@ use App\Http\Controllers\Controller;
|
||||
|
||||
use Illuminate\Support\Facades\Request1;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use App\Models\PrintPatternModel;
|
||||
use App\Models\SizesModel;
|
||||
|
||||
@@ -46,7 +47,7 @@ class PrintPatternController extends Controller {
|
||||
$NewImageName = $templateSize.'.'.$imageExt;
|
||||
|
||||
|
||||
$thumbnail = "uniform-templates/".$templatecode."/".$templateType."/SIZES/" . $NewImageName;
|
||||
$thumbnail = "uploads/images/uniform-templates/".$templatecode."/".$templateType."/SIZES/" . $NewImageName;
|
||||
|
||||
$data = array(
|
||||
'TemplateCode' => $templatecode,
|
||||
@@ -58,9 +59,7 @@ class PrintPatternController extends Controller {
|
||||
$i = $m->insertPrintPattern($data);
|
||||
//var_dump($data);
|
||||
if($i){
|
||||
$r = $request->file('preview_print_template')->move(
|
||||
base_path() . "/public/images/uniform-templates/".$templatecode."/".$templateType."/SIZES/", $NewImageName
|
||||
);
|
||||
Storage::disk('minio')->put('uploads/images/uniform-templates/'.$templatecode.'/'.$templateType.'/SIZES/'.$NewImageName, file_get_contents($request->file('preview_print_template')->getRealPath()));
|
||||
echo '<div class="alert alert-success alert-dismissible">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||||
<h4><i class="icon fa fa-check"></i> Success!</h4>
|
||||
|
||||
@@ -4,6 +4,7 @@ use App\Http\Requests;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use App\Models\TemplatesModel;
|
||||
use App\Models\SportsModel;
|
||||
use App\Models\PrintPatternModel;
|
||||
@@ -48,7 +49,7 @@ class TemplatesController extends Controller {
|
||||
<h3><?php echo $row->TemplateName ?></h3>
|
||||
</div>
|
||||
<div class="sports-border">
|
||||
<a href=""><img src="<?php echo url('public') . "/" . $row->Thumbnail ?>" alt="Sports" height="400px;" class="img img-responsive product-center" /></a>
|
||||
<a href=""><img src="<?php echo minio_url($row->Thumbnail) ?>" alt="Sports" height="400px;" class="img img-responsive product-center" /></a>
|
||||
<div class="sport-edit-btn">
|
||||
<a href="<?php echo url('admin/templates') . "/edit/" . $row->TemplateCode . "/" ?>" class="btn btn-primary btn-block"><i class="fa fa-edit"></i> Edit</a>
|
||||
</div>
|
||||
@@ -129,15 +130,13 @@ class TemplatesController extends Controller {
|
||||
|
||||
|
||||
if($i){
|
||||
$request->file('tempateImage')->move(
|
||||
base_path() . '/public/images/templates/thumbnail', $NewImageName
|
||||
);
|
||||
Storage::disk('minio')->put('images/templates/thumbnail/' . $NewImageName, file_get_contents($request->file('tempateImage')->getRealPath()));
|
||||
|
||||
//for front jersey
|
||||
if(!empty($request->file('svgJerseyFront')->getClientOriginalName())){
|
||||
|
||||
$svgName = $request->file('svgJerseyFront')->getClientOriginalName();
|
||||
$svgThumbnail = "uniform-templates/".$templateCode."/DISPLAY/".$svgName;
|
||||
$svgThumbnail = "uploads/images/uniform-templates/".$templateCode."/DISPLAY/".$svgName;
|
||||
//var_dump($svgThumbnail);
|
||||
$Templatedata = array(
|
||||
'TemplateCode' => $templateCode,
|
||||
@@ -149,16 +148,14 @@ class TemplatesController extends Controller {
|
||||
|
||||
$i = $m->insertTempaltePaths($Templatedata);
|
||||
if($i){
|
||||
$request->file('svgJerseyFront')->move(
|
||||
base_path() . '/public/images/uniform-templates/'.$templateCode. '/DISPLAY' , $svgName
|
||||
);
|
||||
Storage::disk('minio')->put('uploads/images/uniform-templates/'.$templateCode.'/DISPLAY/'.$svgName, file_get_contents($request->file('svgJerseyFront')->getRealPath()));
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($request->file('svgJerseyBack')->getClientOriginalName())){
|
||||
|
||||
$svgName = $request->file('svgJerseyBack')->getClientOriginalName();
|
||||
$svgThumbnail = "uniform-templates/".$templateCode."/DISPLAY/".$svgName;
|
||||
$svgThumbnail = "uploads/images/uniform-templates/".$templateCode."/DISPLAY/".$svgName;
|
||||
|
||||
$Templatedata = array(
|
||||
'TemplateCode' => $templateCode,
|
||||
@@ -170,16 +167,14 @@ class TemplatesController extends Controller {
|
||||
|
||||
$i = $m->insertTempaltePaths($Templatedata);
|
||||
if($i){
|
||||
$request->file('svgJerseyBack')->move(
|
||||
base_path() . '/public/images/uniform-templates/'.$templateCode. '/DISPLAY' , $svgName
|
||||
);
|
||||
Storage::disk('minio')->put('uploads/images/uniform-templates/'.$templateCode.'/DISPLAY/'.$svgName, file_get_contents($request->file('svgJerseyBack')->getRealPath()));
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($request->file('svgShortRight')->getClientOriginalName())){
|
||||
|
||||
$svgName = $request->file('svgShortRight')->getClientOriginalName();
|
||||
$svgThumbnail = "uniform-templates/".$templateCode."/DISPLAY/".$svgName;
|
||||
$svgThumbnail = "uploads/images/uniform-templates/".$templateCode."/DISPLAY/".$svgName;
|
||||
|
||||
$Templatedata = array(
|
||||
'TemplateCode' => $templateCode,
|
||||
@@ -191,16 +186,14 @@ class TemplatesController extends Controller {
|
||||
|
||||
$i = $m->insertTempaltePaths($Templatedata);
|
||||
if($i){
|
||||
$request->file('svgShortRight')->move(
|
||||
base_path() . '/public/images/uniform-templates/'.$templateCode. '/DISPLAY' , $svgName
|
||||
);
|
||||
Storage::disk('minio')->put('uploads/images/uniform-templates/'.$templateCode.'/DISPLAY/'.$svgName, file_get_contents($request->file('svgShortRight')->getRealPath()));
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($request->file('svgShortLeft')->getClientOriginalName())){
|
||||
|
||||
$svgName = $request->file('svgShortLeft')->getClientOriginalName();
|
||||
$svgThumbnail = "uniform-templates/".$templateCode."/DISPLAY/".$svgName;
|
||||
$svgThumbnail = "uploads/images/uniform-templates/".$templateCode."/DISPLAY/".$svgName;
|
||||
|
||||
$Templatedata = array(
|
||||
'TemplateCode' => $templateCode,
|
||||
@@ -212,9 +205,7 @@ class TemplatesController extends Controller {
|
||||
|
||||
$i = $m->insertTempaltePaths($Templatedata);
|
||||
if($i){
|
||||
$request->file('svgShortLeft')->move(
|
||||
base_path() . '/public/images/uniform-templates/'.$templateCode. '/DISPLAY' , $svgName
|
||||
);
|
||||
Storage::disk('minio')->put('uploads/images/uniform-templates/'.$templateCode.'/DISPLAY/'.$svgName, file_get_contents($request->file('svgShortLeft')->getRealPath()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,9 +261,7 @@ class TemplatesController extends Controller {
|
||||
'PatternId' => $getSkins
|
||||
);
|
||||
|
||||
$request->file('tempateImage')->move(
|
||||
base_path() . '/public/images/templates/thumbnail', $NewImageName
|
||||
);
|
||||
Storage::disk('minio')->put('images/templates/thumbnail/' . $NewImageName, file_get_contents($request->file('tempateImage')->getRealPath()));
|
||||
|
||||
}else{
|
||||
|
||||
@@ -298,7 +287,7 @@ class TemplatesController extends Controller {
|
||||
//echo 'meron jerset front';
|
||||
|
||||
$svgName = $request->file('svgJerseyFront')->getClientOriginalName();
|
||||
$svgThumbnail = "uniform-templates/".$templateCode."/DISPLAY/".$svgName;
|
||||
$svgThumbnail = "uploads/images/uniform-templates/".$templateCode."/DISPLAY/".$svgName;
|
||||
|
||||
$Templatedata = array(
|
||||
'Type' => 'Jersey',
|
||||
@@ -308,9 +297,7 @@ class TemplatesController extends Controller {
|
||||
|
||||
$i = $m->updateTemplatePaths($Templatedata, $post['id_svgJerseyFront']);
|
||||
if($i){
|
||||
$request->file('svgJerseyFront')->move(
|
||||
base_path() . '/public/images/uniform-templates/'.$templateCode. '/DISPLAY' , $svgName
|
||||
);
|
||||
Storage::disk('minio')->put('uploads/images/uniform-templates/'.$templateCode.'/DISPLAY/'.$svgName, file_get_contents($request->file('svgJerseyFront')->getRealPath()));
|
||||
//echo 'image move success';
|
||||
}
|
||||
}
|
||||
@@ -318,7 +305,7 @@ class TemplatesController extends Controller {
|
||||
if (array_key_exists('svgJerseyBack', $post)) {
|
||||
|
||||
$svgName = $request->file('svgJerseyBack')->getClientOriginalName();
|
||||
$svgThumbnail = "uniform-templates/".$templateCode."/DISPLAY/".$svgName;
|
||||
$svgThumbnail = "uploads/images/uniform-templates/".$templateCode."/DISPLAY/".$svgName;
|
||||
|
||||
$Templatedata = array(
|
||||
'Type' => 'Jersey',
|
||||
@@ -327,16 +314,13 @@ class TemplatesController extends Controller {
|
||||
);
|
||||
$i = $m->updateTemplatePaths($Templatedata, $post['id_svgJerseyBack']);
|
||||
if($i){
|
||||
|
||||
$request->file('svgJerseyBack')->move(
|
||||
base_path() . '/public/images/uniform-templates/'.$templateCode. '/DISPLAY' , $svgName
|
||||
);
|
||||
Storage::disk('minio')->put('uploads/images/uniform-templates/'.$templateCode.'/DISPLAY/'.$svgName, file_get_contents($request->file('svgJerseyBack')->getRealPath()));
|
||||
}
|
||||
}
|
||||
|
||||
if (array_key_exists('svgShortRight', $post)) {
|
||||
$svgName = $request->file('svgShortRight')->getClientOriginalName();
|
||||
$svgThumbnail = "uniform-templates/".$templateCode."/DISPLAY/".$svgName;
|
||||
$svgThumbnail = "uploads/images/uniform-templates/".$templateCode."/DISPLAY/".$svgName;
|
||||
|
||||
$Templatedata = array(
|
||||
'Type' => 'Shorts',
|
||||
@@ -346,15 +330,13 @@ class TemplatesController extends Controller {
|
||||
|
||||
$i = $m->updateTemplatePaths($Templatedata, $post['id_svgShortRight']);
|
||||
if($i){
|
||||
$request->file('svgShortRight')->move(
|
||||
base_path() . '/public/images/uniform-templates/'.$templateCode. '/DISPLAY' , $svgName
|
||||
);
|
||||
Storage::disk('minio')->put('uploads/images/uniform-templates/'.$templateCode.'/DISPLAY/'.$svgName, file_get_contents($request->file('svgShortRight')->getRealPath()));
|
||||
}
|
||||
}
|
||||
|
||||
if (array_key_exists('svgShortLeft', $post)) {
|
||||
$svgName = $request->file('svgShortLeft')->getClientOriginalName();
|
||||
$svgThumbnail = "uniform-templates/".$templateCode."/DISPLAY/".$svgName;
|
||||
$svgThumbnail = "uploads/images/uniform-templates/".$templateCode."/DISPLAY/".$svgName;
|
||||
|
||||
$Templatedata = array(
|
||||
'Type' => 'Shorts',
|
||||
@@ -364,9 +346,7 @@ class TemplatesController extends Controller {
|
||||
|
||||
$i = $m->updateTemplatePaths($Templatedata, $post['id_svgShortLeft']);
|
||||
if($i){
|
||||
$request->file('svgShortLeft')->move(
|
||||
base_path() . '/public/images/uniform-templates/'.$templateCode. '/DISPLAY' , $svgName
|
||||
);
|
||||
Storage::disk('minio')->put('uploads/images/uniform-templates/'.$templateCode.'/DISPLAY/'.$svgName, file_get_contents($request->file('svgShortLeft')->getRealPath()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user