mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-27 22:49:41 -08:00
Merge remote-tracking branch 'origin/develop'
This commit is contained in:
commit
6b7d5ed5a4
|
@ -13,6 +13,7 @@ use Carbon\Carbon;
|
||||||
use Auth;
|
use Auth;
|
||||||
use DB;
|
use DB;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Requests\ImageUploadRequest;
|
||||||
|
|
||||||
class AccessoriesController extends Controller
|
class AccessoriesController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -86,14 +87,15 @@ class AccessoriesController 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', Accessory::class);
|
$this->authorize('create', Accessory::class);
|
||||||
$accessory = new Accessory;
|
$accessory = new Accessory;
|
||||||
$accessory->fill($request->all());
|
$accessory->fill($request->all());
|
||||||
|
$accessory = $request->handleImages($accessory);
|
||||||
|
|
||||||
if ($accessory->save()) {
|
if ($accessory->save()) {
|
||||||
return response()->json(Helper::formatStandardApiResponse('success', $accessory, trans('admin/accessories/message.create.success')));
|
return response()->json(Helper::formatStandardApiResponse('success', $accessory, trans('admin/accessories/message.create.success')));
|
||||||
|
@ -180,15 +182,16 @@ class AccessoriesController 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', Accessory::class);
|
$this->authorize('update', Accessory::class);
|
||||||
$accessory = Accessory::findOrFail($id);
|
$accessory = Accessory::findOrFail($id);
|
||||||
$accessory->fill($request->all());
|
$accessory->fill($request->all());
|
||||||
|
$accessory = $request->handleImages($accessory);
|
||||||
|
|
||||||
if ($accessory->save()) {
|
if ($accessory->save()) {
|
||||||
return response()->json(Helper::formatStandardApiResponse('success', $accessory, trans('admin/accessories/message.update.success')));
|
return response()->json(Helper::formatStandardApiResponse('success', $accessory, trans('admin/accessories/message.update.success')));
|
||||||
|
|
|
@ -9,6 +9,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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -107,14 +108,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,15 +161,16 @@ 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.
|
||||||
|
|
|
@ -21,6 +21,7 @@ use Auth;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use DB;
|
use DB;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Requests\ImageUploadRequest;
|
||||||
use Input;
|
use Input;
|
||||||
use Paginator;
|
use Paginator;
|
||||||
use Slack;
|
use Slack;
|
||||||
|
@ -425,11 +426,11 @@ class AssetsController extends Controller
|
||||||
* Accepts a POST request to create a new asset
|
* Accepts a POST request to create a new asset
|
||||||
*
|
*
|
||||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||||
* @param Request $request
|
* @param \App\Http\Requests\ImageUploadRequest $request
|
||||||
* @since [v4.0]
|
* @since [v4.0]
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
*/
|
*/
|
||||||
public function store(Request $request)
|
public function store(ImageUploadRequest $request)
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->authorize('create', Asset::class);
|
$this->authorize('create', Asset::class);
|
||||||
|
@ -458,21 +459,15 @@ class AssetsController extends Controller
|
||||||
$asset->rtd_location_id = $request->get('rtd_location_id', null);
|
$asset->rtd_location_id = $request->get('rtd_location_id', null);
|
||||||
$asset->location_id = $request->get('rtd_location_id', null);
|
$asset->location_id = $request->get('rtd_location_id', null);
|
||||||
|
|
||||||
if ($request->has('image_source') && $request->input('image_source') != "") {
|
/**
|
||||||
$saved_image_path = Helper::processUploadedImage(
|
* this is here just legacy reasons. Api\AssetController
|
||||||
$request->input('image_source'), 'uploads/assets/'
|
* used image_source once to allow encoded image uploads.
|
||||||
);
|
*/
|
||||||
|
if ($request->has('image_source')) {
|
||||||
if (!$saved_image_path) {
|
$request->offsetSet('image', $request->offsetGet('image_source'));
|
||||||
return response()->json(Helper::formatStandardApiResponse(
|
|
||||||
'error',
|
|
||||||
null,
|
|
||||||
trans('admin/hardware/message.create.error')
|
|
||||||
), 200);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$asset->image = $saved_image_path;
|
$asset = $request->handleImages($asset);
|
||||||
}
|
|
||||||
|
|
||||||
// Update custom fields in the database.
|
// Update custom fields in the database.
|
||||||
// Validation for these fields is handled through the AssetRequest form request
|
// Validation for these fields is handled through the AssetRequest form request
|
||||||
|
@ -540,11 +535,11 @@ class AssetsController extends Controller
|
||||||
* Accepts a POST request to update an asset
|
* Accepts a POST request to update an asset
|
||||||
*
|
*
|
||||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||||
* @param Request $request
|
* @param \App\Http\Requests\ImageUploadRequest $request
|
||||||
* @since [v4.0]
|
* @since [v4.0]
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
*/
|
*/
|
||||||
public function update(Request $request, $id)
|
public function update(ImageUploadRequest $request, $id)
|
||||||
{
|
{
|
||||||
$this->authorize('update', Asset::class);
|
$this->authorize('update', Asset::class);
|
||||||
|
|
||||||
|
@ -558,31 +553,18 @@ class AssetsController extends Controller
|
||||||
($request->filled('company_id')) ?
|
($request->filled('company_id')) ?
|
||||||
$asset->company_id = Company::getIdForCurrentUser($request->get('company_id')) : '';
|
$asset->company_id = Company::getIdForCurrentUser($request->get('company_id')) : '';
|
||||||
|
|
||||||
($request->filled('rtd_location_id')) ?
|
|
||||||
$asset->location_id = $request->get('rtd_location_id') : null;
|
|
||||||
|
|
||||||
|
|
||||||
if ($request->filled('image_source')) {
|
|
||||||
if ($request->input('image_source') == "") {
|
|
||||||
($request->filled('rtd_location_id')) ?
|
($request->filled('rtd_location_id')) ?
|
||||||
$asset->location_id = $request->get('rtd_location_id') : null;
|
$asset->location_id = $request->get('rtd_location_id') : null;
|
||||||
$asset->image = null;
|
|
||||||
} else {
|
|
||||||
$saved_image_path = Helper::processUploadedImage(
|
|
||||||
$request->input('image_source'), 'uploads/assets/'
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!$saved_image_path) {
|
/**
|
||||||
return response()->json(Helper::formatStandardApiResponse(
|
* this is here just legacy reasons. Api\AssetController
|
||||||
'error',
|
* used image_source once to allow encoded image uploads.
|
||||||
null,
|
*/
|
||||||
trans('admin/hardware/message.update.error')
|
if ($request->has('image_source')) {
|
||||||
), 200);
|
$request->offsetSet('image', $request->offsetGet('image_source'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$asset->image = $saved_image_path;
|
$asset = $request->handleImages($asset);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update custom fields
|
// Update custom fields
|
||||||
if (($model = AssetModel::find($asset->model_id)) && (isset($model->fieldset))) {
|
if (($model = AssetModel::find($asset->model_id)) && (isset($model->fieldset))) {
|
||||||
|
|
|
@ -8,6 +8,7 @@ use App\Http\Transformers\CategoriesTransformer;
|
||||||
use App\Http\Transformers\SelectlistTransformer;
|
use App\Http\Transformers\SelectlistTransformer;
|
||||||
use App\Models\Category;
|
use App\Models\Category;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Requests\ImageUploadRequest;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
class CategoriesController extends Controller
|
class CategoriesController extends Controller
|
||||||
|
@ -54,14 +55,15 @@ class CategoriesController 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', Category::class);
|
$this->authorize('create', Category::class);
|
||||||
$category = new Category;
|
$category = new Category;
|
||||||
$category->fill($request->all());
|
$category->fill($request->all());
|
||||||
|
$category = $request->handleImages($category);
|
||||||
|
|
||||||
if ($category->save()) {
|
if ($category->save()) {
|
||||||
return response()->json(Helper::formatStandardApiResponse('success', $category, trans('admin/categories/message.create.success')));
|
return response()->json(Helper::formatStandardApiResponse('success', $category, trans('admin/categories/message.create.success')));
|
||||||
|
@ -92,15 +94,16 @@ class CategoriesController 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', Category::class);
|
$this->authorize('update', Category::class);
|
||||||
$category = Category::findOrFail($id);
|
$category = Category::findOrFail($id);
|
||||||
$category->fill($request->all());
|
$category->fill($request->all());
|
||||||
|
$category = $request->handleImages($category);
|
||||||
|
|
||||||
if ($category->save()) {
|
if ($category->save()) {
|
||||||
return response()->json(Helper::formatStandardApiResponse('success', $category, trans('admin/categories/message.update.success')));
|
return response()->json(Helper::formatStandardApiResponse('success', $category, trans('admin/categories/message.update.success')));
|
||||||
|
|
|
@ -8,6 +8,7 @@ use App\Http\Transformers\CompaniesTransformer;
|
||||||
use App\Http\Transformers\SelectlistTransformer;
|
use App\Http\Transformers\SelectlistTransformer;
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Requests\ImageUploadRequest;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
class CompaniesController extends Controller
|
class CompaniesController extends Controller
|
||||||
|
@ -65,14 +66,15 @@ class CompaniesController 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', Company::class);
|
$this->authorize('create', Company::class);
|
||||||
$company = new Company;
|
$company = new Company;
|
||||||
$company->fill($request->all());
|
$company->fill($request->all());
|
||||||
|
$company = $request->handleImages($company);
|
||||||
|
|
||||||
if ($company->save()) {
|
if ($company->save()) {
|
||||||
return response()->json(Helper::formatStandardApiResponse('success', (new CompaniesTransformer)->transformCompany($company), trans('admin/companies/message.create.success')));
|
return response()->json(Helper::formatStandardApiResponse('success', (new CompaniesTransformer)->transformCompany($company), trans('admin/companies/message.create.success')));
|
||||||
|
@ -104,15 +106,16 @@ class CompaniesController 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', Company::class);
|
$this->authorize('update', Company::class);
|
||||||
$company = Company::findOrFail($id);
|
$company = Company::findOrFail($id);
|
||||||
$company->fill($request->all());
|
$company->fill($request->all());
|
||||||
|
$company = $request->handleImages($company);
|
||||||
|
|
||||||
if ($company->save()) {
|
if ($company->save()) {
|
||||||
return response()
|
return response()
|
||||||
|
|
|
@ -8,6 +8,7 @@ use App\Http\Transformers\ComponentsTransformer;
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
use App\Models\Component;
|
use App\Models\Component;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Requests\ImageUploadRequest;
|
||||||
use App\Events\CheckoutableCheckedIn;
|
use App\Events\CheckoutableCheckedIn;
|
||||||
use App\Events\ComponentCheckedIn;
|
use App\Events\ComponentCheckedIn;
|
||||||
use App\Models\Asset;
|
use App\Models\Asset;
|
||||||
|
@ -81,14 +82,15 @@ class ComponentsController 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', Component::class);
|
$this->authorize('create', Component::class);
|
||||||
$component = new Component;
|
$component = new Component;
|
||||||
$component->fill($request->all());
|
$component->fill($request->all());
|
||||||
|
$component = $request->handleImages($component);
|
||||||
|
|
||||||
if ($component->save()) {
|
if ($component->save()) {
|
||||||
return response()->json(Helper::formatStandardApiResponse('success', $component, trans('admin/components/message.create.success')));
|
return response()->json(Helper::formatStandardApiResponse('success', $component, trans('admin/components/message.create.success')));
|
||||||
|
@ -119,15 +121,17 @@ class ComponentsController 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', Component::class);
|
$this->authorize('update', Component::class);
|
||||||
$component = Component::findOrFail($id);
|
$component = Component::findOrFail($id);
|
||||||
$component->fill($request->all());
|
$component->fill($request->all());
|
||||||
|
$component = $request->handleImages($component);
|
||||||
|
|
||||||
|
|
||||||
if ($component->save()) {
|
if ($component->save()) {
|
||||||
return response()->json(Helper::formatStandardApiResponse('success', $component, trans('admin/components/message.update.success')));
|
return response()->json(Helper::formatStandardApiResponse('success', $component, trans('admin/components/message.update.success')));
|
||||||
|
|
|
@ -10,6 +10,7 @@ use App\Models\Company;
|
||||||
use App\Models\Consumable;
|
use App\Models\Consumable;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Requests\ImageUploadRequest;
|
||||||
|
|
||||||
class ConsumablesController extends Controller
|
class ConsumablesController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -90,14 +91,15 @@ class ConsumablesController 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', Consumable::class);
|
$this->authorize('create', Consumable::class);
|
||||||
$consumable = new Consumable;
|
$consumable = new Consumable;
|
||||||
$consumable->fill($request->all());
|
$consumable->fill($request->all());
|
||||||
|
$consumable = $request->handleImages($consumable);
|
||||||
|
|
||||||
if ($consumable->save()) {
|
if ($consumable->save()) {
|
||||||
return response()->json(Helper::formatStandardApiResponse('success', $consumable, trans('admin/consumables/message.create.success')));
|
return response()->json(Helper::formatStandardApiResponse('success', $consumable, trans('admin/consumables/message.create.success')));
|
||||||
|
@ -125,15 +127,16 @@ class ConsumablesController 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', Consumable::class);
|
$this->authorize('update', Consumable::class);
|
||||||
$consumable = Consumable::findOrFail($id);
|
$consumable = Consumable::findOrFail($id);
|
||||||
$consumable->fill($request->all());
|
$consumable->fill($request->all());
|
||||||
|
$consumable = $request->handleImages($consumable);
|
||||||
|
|
||||||
if ($consumable->save()) {
|
if ($consumable->save()) {
|
||||||
return response()->json(Helper::formatStandardApiResponse('success', $consumable, trans('admin/consumables/message.update.success')));
|
return response()->json(Helper::formatStandardApiResponse('success', $consumable, trans('admin/consumables/message.update.success')));
|
||||||
|
|
|
@ -9,6 +9,7 @@ use App\Http\Transformers\SelectlistTransformer;
|
||||||
use App\Models\Department;
|
use App\Models\Department;
|
||||||
use Auth;
|
use Auth;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Requests\ImageUploadRequest;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
class DepartmentsController extends Controller
|
class DepartmentsController extends Controller
|
||||||
|
@ -73,14 +74,16 @@ class DepartmentsController 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', Department::class);
|
$this->authorize('create', Department::class);
|
||||||
$department = new Department;
|
$department = new Department;
|
||||||
$department->fill($request->all());
|
$department->fill($request->all());
|
||||||
|
$department = $request->handleImages($department);
|
||||||
|
|
||||||
$department->user_id = Auth::user()->id;
|
$department->user_id = Auth::user()->id;
|
||||||
$department->manager_id = ($request->filled('manager_id' ) ? $request->input('manager_id') : null);
|
$department->manager_id = ($request->filled('manager_id' ) ? $request->input('manager_id') : null);
|
||||||
|
|
||||||
|
@ -111,15 +114,16 @@ class DepartmentsController extends Controller
|
||||||
*
|
*
|
||||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||||
* @since [v5.0]
|
* @since [v5.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', Department::class);
|
$this->authorize('update', Department::class);
|
||||||
$department = Department::findOrFail($id);
|
$department = Department::findOrFail($id);
|
||||||
$department->fill($request->all());
|
$department->fill($request->all());
|
||||||
|
$department = $request->handleImages($department);
|
||||||
|
|
||||||
if ($department->save()) {
|
if ($department->save()) {
|
||||||
return response()->json(Helper::formatStandardApiResponse('success', $department, trans('admin/departments/message.update.success')));
|
return response()->json(Helper::formatStandardApiResponse('success', $department, trans('admin/departments/message.update.success')));
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
namespace App\Http\Controllers\Api;
|
namespace App\Http\Controllers\Api;
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Requests\ImageUploadRequest;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Helpers\Helper;
|
use App\Helpers\Helper;
|
||||||
use App\Models\Location;
|
use App\Models\Location;
|
||||||
|
@ -86,14 +87,15 @@ class LocationsController 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', Location::class);
|
$this->authorize('create', Location::class);
|
||||||
$location = new Location;
|
$location = new Location;
|
||||||
$location->fill($request->all());
|
$location->fill($request->all());
|
||||||
|
$location = $request->handleImages($location);
|
||||||
|
|
||||||
if ($location->save()) {
|
if ($location->save()) {
|
||||||
return response()->json(Helper::formatStandardApiResponse('success', (new LocationsTransformer)->transformLocation($location), trans('admin/locations/message.create.success')));
|
return response()->json(Helper::formatStandardApiResponse('success', (new LocationsTransformer)->transformLocation($location), trans('admin/locations/message.create.success')));
|
||||||
|
@ -141,17 +143,17 @@ class LocationsController 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\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*/
|
*/
|
||||||
public function update(Request $request, $id)
|
public function update(ImageUploadRequest $request, $id)
|
||||||
{
|
{
|
||||||
$this->authorize('update', Location::class);
|
$this->authorize('update', Location::class);
|
||||||
$location = Location::findOrFail($id);
|
$location = Location::findOrFail($id);
|
||||||
|
|
||||||
$location->fill($request->all());
|
$location->fill($request->all());
|
||||||
|
$location = $request->handleImages($location);
|
||||||
|
|
||||||
if ($location->isValid()) {
|
if ($location->isValid()) {
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ use App\Http\Transformers\ManufacturersTransformer;
|
||||||
use App\Http\Transformers\SelectlistTransformer;
|
use App\Http\Transformers\SelectlistTransformer;
|
||||||
use App\Models\Manufacturer;
|
use App\Models\Manufacturer;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Requests\ImageUploadRequest;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
class ManufacturersController extends Controller
|
class ManufacturersController extends Controller
|
||||||
|
@ -59,14 +60,15 @@ class ManufacturersController 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', Manufacturer::class);
|
$this->authorize('create', Manufacturer::class);
|
||||||
$manufacturer = new Manufacturer;
|
$manufacturer = new Manufacturer;
|
||||||
$manufacturer->fill($request->all());
|
$manufacturer->fill($request->all());
|
||||||
|
$manufacturer = $request->handleImages($manufacturer);
|
||||||
|
|
||||||
if ($manufacturer->save()) {
|
if ($manufacturer->save()) {
|
||||||
return response()->json(Helper::formatStandardApiResponse('success', $manufacturer, trans('admin/manufacturers/message.create.success')));
|
return response()->json(Helper::formatStandardApiResponse('success', $manufacturer, trans('admin/manufacturers/message.create.success')));
|
||||||
|
@ -96,15 +98,16 @@ class ManufacturersController 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', Manufacturer::class);
|
$this->authorize('update', Manufacturer::class);
|
||||||
$manufacturer = Manufacturer::findOrFail($id);
|
$manufacturer = Manufacturer::findOrFail($id);
|
||||||
$manufacturer->fill($request->all());
|
$manufacturer->fill($request->all());
|
||||||
|
$manufacturer = $request->handleImages($manufacturer);
|
||||||
|
|
||||||
if ($manufacturer->save()) {
|
if ($manufacturer->save()) {
|
||||||
return response()->json(Helper::formatStandardApiResponse('success', $manufacturer, trans('admin/manufacturers/message.update.success')));
|
return response()->json(Helper::formatStandardApiResponse('success', $manufacturer, trans('admin/manufacturers/message.update.success')));
|
||||||
|
|
|
@ -8,6 +8,7 @@ use App\Http\Transformers\SelectlistTransformer;
|
||||||
use App\Http\Transformers\SuppliersTransformer;
|
use App\Http\Transformers\SuppliersTransformer;
|
||||||
use App\Models\Supplier;
|
use App\Models\Supplier;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use App\http\Requests\ImageUploadRequest;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
class SuppliersController extends Controller
|
class SuppliersController extends Controller
|
||||||
|
@ -55,14 +56,15 @@ class SuppliersController 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', Supplier::class);
|
$this->authorize('create', Supplier::class);
|
||||||
$supplier = new Supplier;
|
$supplier = new Supplier;
|
||||||
$supplier->fill($request->all());
|
$supplier->fill($request->all());
|
||||||
|
$supplier = $request->handleImages($supplier);
|
||||||
|
|
||||||
if ($supplier->save()) {
|
if ($supplier->save()) {
|
||||||
return response()->json(Helper::formatStandardApiResponse('success', $supplier, trans('admin/suppliers/message.create.success')));
|
return response()->json(Helper::formatStandardApiResponse('success', $supplier, trans('admin/suppliers/message.create.success')));
|
||||||
|
@ -92,15 +94,16 @@ class SuppliersController 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', Supplier::class);
|
$this->authorize('update', Supplier::class);
|
||||||
$supplier = Supplier::findOrFail($id);
|
$supplier = Supplier::findOrFail($id);
|
||||||
$supplier->fill($request->all());
|
$supplier->fill($request->all());
|
||||||
|
$supplier = $request->handleImages($supplier);
|
||||||
|
|
||||||
if ($supplier->save()) {
|
if ($supplier->save()) {
|
||||||
return response()->json(Helper::formatStandardApiResponse('success', $supplier, trans('admin/suppliers/message.update.success')));
|
return response()->json(Helper::formatStandardApiResponse('success', $supplier, trans('admin/suppliers/message.update.success')));
|
||||||
|
|
|
@ -16,6 +16,7 @@ use App\Models\License;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Auth;
|
use Auth;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Requests\ImageUploadRequest;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
class UsersController extends Controller
|
class UsersController extends Controller
|
||||||
|
@ -237,6 +238,7 @@ class UsersController extends Controller
|
||||||
$tmp_pass = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 20);
|
$tmp_pass = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 20);
|
||||||
$user->password = bcrypt($request->get('password', $tmp_pass));
|
$user->password = bcrypt($request->get('password', $tmp_pass));
|
||||||
|
|
||||||
|
app('App\Http\Requests\ImageUploadRequest')->handleImages($user, 600, 'image', 'avatars', 'avatar');
|
||||||
|
|
||||||
if ($user->save()) {
|
if ($user->save()) {
|
||||||
if ($request->filled('groups')) {
|
if ($request->filled('groups')) {
|
||||||
|
@ -320,6 +322,9 @@ class UsersController extends Controller
|
||||||
Asset::where('assigned_type', User::class)
|
Asset::where('assigned_type', User::class)
|
||||||
->where('assigned_to', $user->id)->update(['location_id' => $request->input('location_id', null)]);
|
->where('assigned_to', $user->id)->update(['location_id' => $request->input('location_id', null)]);
|
||||||
|
|
||||||
|
|
||||||
|
app('App\Http\Requests\ImageUploadRequest')->handleImages($user, 600, 'image', 'avatars', 'avatar');
|
||||||
|
|
||||||
if ($user->save()) {
|
if ($user->save()) {
|
||||||
|
|
||||||
// Sync group memberships:
|
// Sync group memberships:
|
||||||
|
|
|
@ -5,10 +5,14 @@ namespace App\Http\Requests;
|
||||||
use App\Models\SnipeModel;
|
use App\Models\SnipeModel;
|
||||||
use Intervention\Image\Facades\Image;
|
use Intervention\Image\Facades\Image;
|
||||||
use enshrined\svgSanitize\Sanitizer;
|
use enshrined\svgSanitize\Sanitizer;
|
||||||
|
use App\Http\Traits\ConvertsBase64ToFiles;
|
||||||
|
use Illuminate\Http\UploadedFile;
|
||||||
use Storage;
|
use Storage;
|
||||||
|
|
||||||
class ImageUploadRequest extends Request
|
class ImageUploadRequest extends Request
|
||||||
{
|
{
|
||||||
|
use ConvertsBase64ToFiles;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if the user is authorized to make this request.
|
* Determine if the user is authorized to make this request.
|
||||||
*
|
*
|
||||||
|
@ -26,6 +30,7 @@ class ImageUploadRequest extends Request
|
||||||
*/
|
*/
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'image' => 'mimes:png,gif,jpg,jpeg,svg,bmp,svg+xml,webp',
|
'image' => 'mimes:png,gif,jpg,jpeg,svg,bmp,svg+xml,webp',
|
||||||
'avatar' => 'mimes:png,gif,jpg,jpeg,svg,bmp,svg+xml,webp',
|
'avatar' => 'mimes:png,gif,jpg,jpeg,svg,bmp,svg+xml,webp',
|
||||||
|
@ -37,6 +42,21 @@ class ImageUploadRequest extends Request
|
||||||
return $this->redirector->back()->withInput()->withErrors($errors, $this->errorBag);
|
return $this->redirector->back()->withInput()->withErrors($errors, $this->errorBag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fields that should be traited from base64 to files
|
||||||
|
*/
|
||||||
|
protected function base64FileKeys(): array
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* image_source is here just legacy reasons. Api\AssetController
|
||||||
|
* had it once to allow encoded image uploads.
|
||||||
|
*/
|
||||||
|
return [
|
||||||
|
'image' => 'auto',
|
||||||
|
'image_source' => 'auto'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle and store any images attached to request
|
* Handle and store any images attached to request
|
||||||
* @param SnipeModel $item Item the image is associated with
|
* @param SnipeModel $item Item the image is associated with
|
||||||
|
@ -78,13 +98,21 @@ class ImageUploadRequest extends Request
|
||||||
\Log::debug('DB fieldname is: '.$use_db_field);
|
\Log::debug('DB fieldname is: '.$use_db_field);
|
||||||
\Log::debug('Trying to upload to '. $path);
|
\Log::debug('Trying to upload to '. $path);
|
||||||
|
|
||||||
\Log::debug($this->file());
|
// ConvertBase64ToFiles just changes object type,
|
||||||
|
// as it cannot currently insert files to $this->files
|
||||||
|
if ($this->offsetGet($form_fieldname) instanceof UploadedFile) {
|
||||||
|
$image=$this->offsetGet($form_fieldname);
|
||||||
|
} else {
|
||||||
if ($this->hasFile($form_fieldname)) {
|
if ($this->hasFile($form_fieldname)) {
|
||||||
|
$image = $this->file($form_fieldname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($image)) {
|
||||||
|
\Log::debug($image);
|
||||||
|
|
||||||
if (!config('app.lock_passwords')) {
|
if (!config('app.lock_passwords')) {
|
||||||
|
|
||||||
$image = $this->file($form_fieldname);
|
|
||||||
$ext = $image->getClientOriginalExtension();
|
$ext = $image->getClientOriginalExtension();
|
||||||
$file_name = $type.'-'.$form_fieldname.'-'.str_random(10).'.'.$ext;
|
$file_name = $type.'-'.$form_fieldname.'-'.str_random(10).'.'.$ext;
|
||||||
|
|
||||||
|
@ -165,4 +193,5 @@ class ImageUploadRequest extends Request
|
||||||
|
|
||||||
return $item;
|
return $item;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
80
app/Http/Traits/ConvertsBase64ToFiles.php
Normal file
80
app/Http/Traits/ConvertsBase64ToFiles.php
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Traits;
|
||||||
|
|
||||||
|
use Illuminate\Http\UploadedFile;
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
trait ConvertsBase64ToFiles
|
||||||
|
{
|
||||||
|
protected function base64FileKeys(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pulls the Base64 contents for each file key and creates
|
||||||
|
* an UploadedFile instance from it and sets it on the
|
||||||
|
* request.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function prepareForValidation()
|
||||||
|
{
|
||||||
|
$flattened = Arr::dot($this->base64FileKeys());
|
||||||
|
|
||||||
|
Collection::make($flattened)->each(function ($filename, $key) {
|
||||||
|
rescue(function () use ($key, $filename) {
|
||||||
|
// dont process plain files
|
||||||
|
if ( $this->file($key)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$base64Contents = $this->input($key);
|
||||||
|
|
||||||
|
if (!$base64Contents) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// autogenerate filenames
|
||||||
|
if ($filename == 'auto'){
|
||||||
|
$header = explode(';', $base64Contents, 2)[0];
|
||||||
|
// Grab the image type from the header while we're at it.
|
||||||
|
$filename = $key . '.' . substr($header, strpos($header, '/')+1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate a temporary path to store the Base64 contents
|
||||||
|
$tempFilePath = tempnam(sys_get_temp_dir(), $filename);
|
||||||
|
|
||||||
|
// Store the contents using a stream, or by decoding manually
|
||||||
|
if (Str::startsWith($base64Contents, 'data:') && count(explode(',', $base64Contents)) > 1) {
|
||||||
|
$source = fopen($base64Contents, 'r');
|
||||||
|
$destination = fopen($tempFilePath, 'w');
|
||||||
|
|
||||||
|
stream_copy_to_stream($source, $destination);
|
||||||
|
|
||||||
|
fclose($source);
|
||||||
|
fclose($destination);
|
||||||
|
} else {
|
||||||
|
file_put_contents($tempFilePath, base64_decode($base64Contents, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
$uploadedFile = new UploadedFile($tempFilePath, $filename, null, null, true);
|
||||||
|
|
||||||
|
\Log::debug("Trait: uploadedfile ". $tempFilePath);
|
||||||
|
$this->offsetUnset($key);
|
||||||
|
\Log::debug("Trait: encoded field \"$key\" removed" );
|
||||||
|
|
||||||
|
//Inserting new file to $this-files does not work so have to deal this after
|
||||||
|
$this->offsetSet($key,$uploadedFile);
|
||||||
|
\Log::debug("Trait: field \"$key\" inserted as UplodedFile" );
|
||||||
|
|
||||||
|
}, null, false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Loosely based on idea https://github.com/protonemedia/laravel-mixins/tree/master/src/Request
|
||||||
|
* */
|
Loading…
Reference in a new issue