mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 05:34:06 -08:00
Support images and multipart requests
This commit is contained in:
parent
5081ca3512
commit
60f13c8d79
|
@ -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
|
||||||
|
@ -53,14 +54,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')));
|
||||||
|
@ -90,15 +92,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')));
|
||||||
|
|
Loading…
Reference in a new issue