From 9effa3d2ab8ad62d8626d268465ac52e6f165ce3 Mon Sep 17 00:00:00 2001 From: snipe Date: Sat, 3 Mar 2018 19:14:27 -0800 Subject: [PATCH] Fixed manufacturer restore --- app/Http/Controllers/ManufacturersController.php | 12 ++++++++---- app/Models/Manufacturer.php | 2 -- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/ManufacturersController.php b/app/Http/Controllers/ManufacturersController.php index 5171cefad0..1d84fa37d2 100755 --- a/app/Http/Controllers/ManufacturersController.php +++ b/app/Http/Controllers/ManufacturersController.php @@ -247,7 +247,7 @@ class ManufacturersController extends Controller * * @author [A. Gianotto] [] * @since [v4.1.15] - * @param int $id + * @param int $manufacturers_id * @return Redirect */ public function restore($manufacturers_id) @@ -256,9 +256,13 @@ class ManufacturersController extends Controller $manufacturer = Manufacturer::onlyTrashed()->where('id',$manufacturers_id)->first(); if ($manufacturer) { - // I don't know why $manufacturer->restore(); didn't work here... - $manufacturer->restore(); - return redirect()->route('manufacturers.index')->with('success', trans('admin/manufacturers/message.restore.success')); + + // Not sure why this is necessary - it shouldn't fail validation here, but it fails without this, so.... + $manufacturer->setValidating(false); + if ($manufacturer->restore()) { + return redirect()->route('manufacturers.index')->with('success', trans('admin/manufacturers/message.restore.success')); + } + return redirect()->back()->with('error', 'Could not restore.'); } return redirect()->back()->with('error', trans('admin/manufacturers/message.does_not_exist')); diff --git a/app/Models/Manufacturer.php b/app/Models/Manufacturer.php index bc1e806305..5cd7bcc15d 100755 --- a/app/Models/Manufacturer.php +++ b/app/Models/Manufacturer.php @@ -23,8 +23,6 @@ class Manufacturer extends SnipeModel protected $hidden = ['user_id']; - - /** * Whether the model should inject it's identifier to the unique * validation rules before attempting validation. If this property