mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Revert asset-checkout-different validation.
This was causing issues when trying to check an item out to a user or a location because of the way laravel handles validation. Instead, rely on the exception check we had in the controller. I moved this exception up to the model checkout method so that it would work for anywhere that that method was called, even if it avoided the controller.
This commit is contained in:
parent
c34650458f
commit
f8d18a8eb0
|
@ -62,9 +62,7 @@ class AssetCheckoutController extends Controller
|
|||
$admin = Auth::user();
|
||||
|
||||
$target = $this->determineCheckoutTarget($asset);
|
||||
if ($asset->is($target)) {
|
||||
throw new CheckoutNotAllowed('You cannot check an asset out to itself.');
|
||||
}
|
||||
|
||||
$asset = $this->updateAssetLocation($asset, $target);
|
||||
|
||||
$checkout_at = date("Y-m-d H:i:s");
|
||||
|
|
|
@ -23,7 +23,7 @@ class AssetCheckoutRequest extends Request
|
|||
{
|
||||
$rules = [
|
||||
"assigned_user" => 'required_without_all:assigned_asset,assigned_location',
|
||||
"assigned_asset" => 'required_without_all:assigned_user,assigned_location|different:'.$this->id,
|
||||
"assigned_asset" => 'required_without_all:assigned_user,assigned_location',
|
||||
"assigned_location" => 'required_without_all:assigned_user,assigned_asset',
|
||||
"checkout_to_type" => 'required|in:asset,location,user'
|
||||
];
|
||||
|
|
|
@ -3,6 +3,7 @@ namespace App\Models;
|
|||
|
||||
use App\Events\AssetCheckedOut;
|
||||
use App\Events\CheckoutableCheckedOut;
|
||||
use App\Exceptions\CheckoutNotAllowed;
|
||||
use App\Http\Traits\UniqueSerialTrait;
|
||||
use App\Http\Traits\UniqueUndeletedTrait;
|
||||
use App\Models\Traits\Acceptable;
|
||||
|
@ -271,6 +272,9 @@ class Asset extends Depreciable
|
|||
if (!$target) {
|
||||
return false;
|
||||
}
|
||||
if ($this->is($target)) {
|
||||
throw new CheckoutNotAllowed('You cannot check an asset out to itself.');
|
||||
}
|
||||
|
||||
if ($expected_checkin) {
|
||||
$this->expected_checkin = $expected_checkin;
|
||||
|
|
Loading…
Reference in a new issue