where('is_history', 0)->first(); if ($dish_name) { $dish_name = $dish_name['name']; } else { $dish_name = Dishes::where('code', $data)->where('is_history', 1)->first(); if ($dish_name) { $dish_name = $dish_name['name']; } else { $dish_name = 'Связанный товар удален'; } } if ($dish_name == 'Связанный товар удален') { $dish_name = Dishes::where('legacy_code', $data)->where('is_history', 0)->first(); if ($dish_name) { $dish_name = $dish_name['name']; } else { $dish_name = Dishes::where('legacy_code', $data)->where('is_history', 1)->first(); if ($dish_name) { $dish_name = $dish_name['name']; } else { $dish_name = 'Связанный товар удален'; } } } return $dish_name; } public static function isReal($data) { $dish_isReal = Dishes::where('code', $data)->where('is_history', 0)->first(); $isReal = 0; if ($dish_isReal) { $isReal = intval($dish_isReal['real_count']); } else { $dish_isReal = Dishes::where('code', $data)->where('is_history', 1)->first(); if ($dish_isReal) { $isReal = intval($dish_isReal['real_count']); } else { $isReal = 0; } } return $isReal; } public static function isServing($data) { $dish_isServing = Dishes::where('code', $data)->where('is_history', 0)->first(); $isServing = 0; if ($dish_isServing) { $isServing = intval($dish_isServing['is_serving']); } else { $dish_isServing = Dishes::where('code', $data)->where('is_history', 1)->first(); if ($dish_isServing) { $isServing = intval($dish_isServing['is_serving']); } else { $isServing = 0; } } return $isServing; } public static function GetPrinterCode($data) { $dish = Dishes::where('legacy_code', $data)->where('is_history', 0)->first(); if ($dish) { $printer_code = $dish['printer_code']; } else { $dish = Dishes::where('legacy_code', $data)->where('is_history', 1)->first(); if ($dish) { $printer_code = $dish['printer_code']; } else { $printer_code = 0; } } if ($printer_code == 0) { $dish = Dishes::where('code', $data)->where('is_history', 0)->first(); if ($dish) { $printer_code = $dish['printer_code']; } else { $dish = Dishes::where('code', $data)->where('is_history', 1)->first(); if ($dish) { $printer_code = $dish['printer_code']; } else { $printer_code = 0; } } } return $printer_code; } }