product_repo = $product_repo; } /** */ public function index(ProductFilters $filters) { $products = Product::filter($filters); return $this->listResponse($products); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create(CreateProductRequest $request) { $product = ProductFactory::create(auth()->user()->company()->id, auth()->user()->id); return $this->itemResponse($product); } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(StoreProductRequest $request) { $product = $this->product_repo->save($request, ProductFactory::create(auth()->user()->company()->id, auth()->user()->id)); return $this->itemResponse($product); } /** * Display the specified resource. * * @param Product $product * @return \Illuminate\Http\Response */ public function show(ShowProductRequest $request, Product $product) { return $this->itemResponse($product); } /** * Show the form for editing the specified resource. * * @param Product $product * @return \Illuminate\Http\Response */ public function edit(EditProductRequest $request, Product $product) { return $this->itemResponse($product); } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param Product $product * @return \Illuminate\Http\Response */ public function update(UpdateProductRequest $request, Product $product) { $product = $this->product_repo->save($request, $product); return $this->itemResponse($product); } /** * Remove the specified resource from storage. * * @param Product $product * @return \Illuminate\Http\Response */ public function destroy(Product $product) { $product->delete(); return response()->json([], 200); } /** * Perform bulk actions on the list view * * @return Collection */ public function bulk() { $action = request()->input('action'); $ids = request()->input('ids'); $products = Product::withTrashed()->find($ids); $products->each(function ($product, $key) use($action){ if(auth()->user()->can('edit', $product)) ActionEntity::dispatchNow($product, $action); }); //todo need to return the updated dataset return response()->json([], 200); } }