mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-13 06:47:46 -08:00
not all working, but pushing to work on something else
This commit is contained in:
parent
c025e25839
commit
eac01868ca
|
@ -622,10 +622,9 @@ class AssetsController extends Controller
|
|||
* @since [v4.0]
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function update(UpdateAssetRequest $request, Asset $id)
|
||||
public function update(UpdateAssetRequest $request, Asset $asset)
|
||||
{
|
||||
if ($asset = Asset::find($id)) {
|
||||
$asset->fill($request->validated());
|
||||
$asset->update($request->validated());
|
||||
|
||||
// TODO: how much of this should go to validator?
|
||||
($request->filled('model_id')) ?
|
||||
|
@ -689,11 +688,8 @@ class AssetsController extends Controller
|
|||
}
|
||||
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, $asset->getErrors()), 200);
|
||||
}
|
||||
|
||||
// TODO: can this be moved up to ModelNotFound exception handler? would remove a couple lines here if we could use laravel's awesome route-model binding.
|
||||
// (would also need to confirm that then _everything_ expects a 200 when a model isn't found)
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/hardware/message.does_not_exist')), 200);
|
||||
// TODO: confirm that everything expects a _200_ model not found exception
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
namespace App\Http\Requests;
|
||||
|
||||
use App\Models\Asset;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
class UpdateAssetRequest extends ImageUploadRequest
|
||||
|
@ -20,6 +19,10 @@ class UpdateAssetRequest extends ImageUploadRequest
|
|||
|
||||
public function prepareForValidation()
|
||||
{
|
||||
dump($this->asset);
|
||||
$asset = $this->route('asset');
|
||||
dump($asset);
|
||||
dump($this->route()->getName());
|
||||
// the following are 'required' attributes that may or may not be present on an patch request
|
||||
// so supplying them here instead of doing funky array modification to the rules
|
||||
if (!$this->has('asset_tag')) {
|
||||
|
|
Loading…
Reference in a new issue