mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-23 11:43:47 -08:00
* Fixes the validation rules on Manufacturer Model * Fixes a little issue; if the manufacturer is active soft-deletes it, if is already deleted permanently deletes it
This commit is contained in:
parent
681c41bd18
commit
f89d789832
|
@ -158,7 +158,7 @@ class ManufacturersController extends Controller
|
|||
public function destroy($manufacturerId)
|
||||
{
|
||||
$this->authorize('delete', Manufacturer::class);
|
||||
if (is_null($manufacturer = Manufacturer::withCount('models as models_count')->find($manufacturerId))) {
|
||||
if (is_null($manufacturer = Manufacturer::withTrashed()->withCount('models as models_count')->find($manufacturerId))) {
|
||||
return redirect()->route('manufacturers.index')->with('error', trans('admin/manufacturers/message.not_found'));
|
||||
}
|
||||
|
||||
|
@ -174,8 +174,12 @@ class ManufacturersController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
// Delete the manufacturer
|
||||
$manufacturer->delete();
|
||||
// Soft delete the manufacturer if active, permanent delete if is already deleted
|
||||
if($manufacturer->deleted_at === NULL) {
|
||||
$manufacturer->delete();
|
||||
} else {
|
||||
$manufacturer->forceDelete();
|
||||
}
|
||||
// Redirect to the manufacturers management page
|
||||
return redirect()->route('manufacturers.index')->with('success', trans('admin/manufacturers/message.delete.success'));
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ class Manufacturer extends SnipeModel
|
|||
|
||||
// Declare the rules for the form validation
|
||||
protected $rules = array(
|
||||
'name' => 'required|min:2|max:255|unique:manufacturers,name,NULL,deleted_at',
|
||||
'name' => 'required|min:2|max:255|unique:manufacturers,name,NULL,id,deleted_at,NULL',
|
||||
'url' => 'url|nullable',
|
||||
'support_url' => 'url|nullable',
|
||||
'support_email' => 'email|nullable'
|
||||
|
|
Loading…
Reference in a new issue