public function return_item_ina_to_act(Request $request) { if ($request->ajax()) { $factory_item_id = $request->input('factory_item_id'); $factory_item = Factoryitem::find($factory_item_id); if ($factory_item !== null) { $last_update_factory_item = Factoryitem::where('itemsid', $factory_item->itemsid)->where('salesid', $factory_item->salesid)->where('status', 1)->where('sale_product', 1)->orderBy('id', 'DESC')->first(); if ($last_update_factory_item !== null) { $last_update_factory_item->salesid = NULL; $last_update_factory_item->sale_product = 0; $last_update_factory_item->save(); $factory_item->status = 1; $factory_item->save(); return response()->json(1); // return successfully } else { return response()->json(2); // Not found last inactive } } else { return response()->json(0); //Not found thid product. } } }
public function download_csv_damaged(Request $request, $id) { if ($request->ajax()) { $search_value = $request->input('search_value'); if ($search_value == NULL) { $download_csv_data = Factoryitem::damage($id); $item = Item::find($id); return response()->json(array('download_csv_data' => $download_csv_data, 'item' => $item)); } else { $download_csv_data = Factoryitem::where('itemsid', $id)->where(function ($query) use($search_value) { $query->where('slno', 'like', '%' . $search_value . '%')->orWhere('created_at', 'like', '%' . $search_value . '%'); })->where('status', 0)->get(); $item = Item::find($id); return response()->json(array('download_csv_data' => $download_csv_data, 'item' => $item)); } } }