mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 05:04:07 -08:00
Support images and multipart requests
This commit is contained in:
parent
f6766c5f23
commit
b4380c8012
|
@ -10,6 +10,7 @@ use App\Http\Transformers\SelectlistTransformer;
|
||||||
use App\Models\Asset;
|
use App\Models\Asset;
|
||||||
use App\Models\AssetModel;
|
use App\Models\AssetModel;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Requests\ImageUploadRequest;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -106,14 +107,15 @@ class AssetModelsController extends Controller
|
||||||
*
|
*
|
||||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||||
* @since [v4.0]
|
* @since [v4.0]
|
||||||
* @param \Illuminate\Http\Request $request
|
* @param \App\Http\Requests\ImageUploadRequest $request
|
||||||
* @return \Illuminate\Http\Response
|
* @return \Illuminate\Http\Response
|
||||||
*/
|
*/
|
||||||
public function store(Request $request)
|
public function store(ImageUploadRequest $request)
|
||||||
{
|
{
|
||||||
$this->authorize('create', AssetModel::class);
|
$this->authorize('create', AssetModel::class);
|
||||||
$assetmodel = new AssetModel;
|
$assetmodel = new AssetModel;
|
||||||
$assetmodel->fill($request->all());
|
$assetmodel->fill($request->all());
|
||||||
|
$assetmodel = $request->handleImages($assetmodel);
|
||||||
|
|
||||||
if ($assetmodel->save()) {
|
if ($assetmodel->save()) {
|
||||||
return response()->json(Helper::formatStandardApiResponse('success', $assetmodel, trans('admin/models/message.create.success')));
|
return response()->json(Helper::formatStandardApiResponse('success', $assetmodel, trans('admin/models/message.create.success')));
|
||||||
|
@ -159,16 +161,17 @@ class AssetModelsController extends Controller
|
||||||
*
|
*
|
||||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||||
* @since [v4.0]
|
* @since [v4.0]
|
||||||
* @param \Illuminate\Http\Request $request
|
* @param \App\Http\Requests\ImageUploadRequest $request
|
||||||
* @param int $id
|
* @param int $id
|
||||||
* @return \Illuminate\Http\Response
|
* @return \Illuminate\Http\Response
|
||||||
*/
|
*/
|
||||||
public function update(Request $request, $id)
|
public function update(ImageUploadRequest $request, $id)
|
||||||
{
|
{
|
||||||
$this->authorize('update', AssetModel::class);
|
$this->authorize('update', AssetModel::class);
|
||||||
$assetmodel = AssetModel::findOrFail($id);
|
$assetmodel = AssetModel::findOrFail($id);
|
||||||
$assetmodel->fill($request->all());
|
$assetmodel->fill($request->all());
|
||||||
|
$assetmodel = $request->handleImages($assetmodel);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allow custom_fieldset_id to override and populate fieldset_id.
|
* Allow custom_fieldset_id to override and populate fieldset_id.
|
||||||
* This is stupid, but required for legacy API support.
|
* This is stupid, but required for legacy API support.
|
||||||
|
|
Loading…
Reference in a new issue