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:
Daniel Meltzer
2020-04-29 10:59:00 -04:00
parent c34650458f
commit f8d18a8eb0
3 changed files with 6 additions and 4 deletions
+4
View File
@@ -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;