mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-11 22:07:29 -08:00
Support images and multipart requests
This commit is contained in:
parent
b4380c8012
commit
5081ca3512
|
@ -21,6 +21,7 @@ use Carbon\Carbon;
|
|||
use DB;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use App\Http\Requests\ImageUploadRequest;
|
||||
use Input;
|
||||
use Paginator;
|
||||
use Slack;
|
||||
|
@ -404,11 +405,11 @@ class AssetsController extends Controller
|
|||
* Accepts a POST request to create a new asset
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @param Request $request
|
||||
* @param \App\Http\Requests\ImageUploadRequest $request
|
||||
* @since [v4.0]
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function store(Request $request)
|
||||
public function store(ImageUploadRequest $request)
|
||||
{
|
||||
$this->authorize('create', Asset::class);
|
||||
|
||||
|
@ -452,6 +453,8 @@ class AssetsController extends Controller
|
|||
$asset->image = $saved_image_path;
|
||||
}
|
||||
|
||||
$asset = $request->handleImages($asset);
|
||||
|
||||
// Update custom fields in the database.
|
||||
// Validation for these fields is handled through the AssetRequest form request
|
||||
$model = AssetModel::find($request->get('model_id'));
|
||||
|
@ -513,11 +516,11 @@ class AssetsController extends Controller
|
|||
* Accepts a POST request to update an asset
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @param Request $request
|
||||
* @param \App\Http\Requests\ImageUploadRequest $request
|
||||
* @since [v4.0]
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
public function update(ImageUploadRequest $request, $id)
|
||||
{
|
||||
$this->authorize('update', Asset::class);
|
||||
|
||||
|
@ -556,6 +559,8 @@ class AssetsController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
$asset = $request->handleImages($asset);
|
||||
|
||||
// Update custom fields
|
||||
if (($model = AssetModel::find($asset->model_id)) && (isset($model->fieldset))) {
|
||||
foreach ($model->fieldset->fields as $field) {
|
||||
|
|
Loading…
Reference in a new issue