Skip to content

Commit

Permalink
Fixed manufacturer restore
Browse files Browse the repository at this point in the history
  • Loading branch information
snipe committed Mar 4, 2018
1 parent 0782222 commit 9effa3d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 8 additions & 4 deletions app/Http/Controllers/ManufacturersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public function show($manufacturerId = null)
*
* @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.1.15]
* @param int $id
* @param int $manufacturers_id
* @return Redirect
*/
public function restore($manufacturers_id)
Expand All @@ -256,9 +256,13 @@ public function restore($manufacturers_id)
$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'));

Expand Down
2 changes: 0 additions & 2 deletions app/Models/Manufacturer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9effa3d

Please sign in to comment.