public function getAddToStock($import_id, $to_stock_id) { $stockInvoces = new StockInvoice(); $stockDetails = new StockDetail(); $invoiceId = $stockInvoces->invoice_id = $this->generateInvoiceId(); $import = Import::find($import_id); $import_details = ImportDetail::where('import_num', '=', $import_id)->where('stock_in_status', '=', '0')->get(); if (!empty($import_details[0])) { $this->insertStockData($stockInvoces, $import, $invoiceId); } foreach ($import_details as $row) { $this->setStockData($import, $row, $stockDetails, $invoiceId, $to_stock_id); } Session::flash('message', 'Product added to the stock successfully'); return Redirect::to('imports/details/' . $import->id); //$list = $this->setStockData($import, $stockDetails); }
public function getChangeStatus($status, $id) { $import = Import::find($id); if ($import['status'] == $status) { $import->status = $status == 'Activate' ? 'Deactivate' : 'Activate'; $import->save(); } return new JsonResponse(array('id' => $import['id'], 'status' => $import['status'])); }