mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-12 22:37:28 -08:00
Apply model image fix to update method
This commit is contained in:
parent
554ea8bb95
commit
e461c25428
|
@ -188,7 +188,7 @@ class AssetModelsController extends Controller
|
||||||
* @param int $modelId
|
* @param int $modelId
|
||||||
* @return Redirect
|
* @return Redirect
|
||||||
*/
|
*/
|
||||||
public function update(Request $request, $modelId = null)
|
public function update(ImageUploadRequest $request, $modelId = null)
|
||||||
{
|
{
|
||||||
// Check if the model exists
|
// Check if the model exists
|
||||||
if (is_null($model = AssetModel::find($modelId))) {
|
if (is_null($model = AssetModel::find($modelId))) {
|
||||||
|
@ -214,13 +214,19 @@ class AssetModelsController extends Controller
|
||||||
|
|
||||||
if (Input::file('image')) {
|
if (Input::file('image')) {
|
||||||
$image = Input::file('image');
|
$image = Input::file('image');
|
||||||
$file_name = str_random(25).".".$image->getClientOriginalExtension();
|
$file_name = str_random(25) . "." . $image->getClientOriginalExtension();
|
||||||
$path = public_path('uploads/models/'.$file_name);
|
$path = public_path('uploads/models/');
|
||||||
Image::make($image->getRealPath())->resize(300, null, function ($constraint) {
|
|
||||||
$constraint->aspectRatio();
|
if ($image->getClientOriginalExtension()!='svg') {
|
||||||
$constraint->upsize();
|
Image::make($image->getRealPath())->resize(500, null, function ($constraint) {
|
||||||
})->save($path);
|
$constraint->aspectRatio();
|
||||||
|
$constraint->upsize();
|
||||||
|
})->save($path.'/'.$file_name);
|
||||||
|
} else {
|
||||||
|
$image->move($path, $file_name);
|
||||||
|
}
|
||||||
$model->image = $file_name;
|
$model->image = $file_name;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($request->input('image_delete') == 1 && Input::file('image') == "") {
|
if ($request->input('image_delete') == 1 && Input::file('image') == "") {
|
||||||
|
|
Loading…
Reference in a new issue