public function __construct($db) { $this->orm = $db; $this->db = $db->db(); $this->table = $db->table(); $dir = Config::get('dir.blizz.store', session_save_path()); if (!is_dir($dir)) { File::mkdir($dir); } $dir .= DS . Inflector::urlize(Inflector::uncamelize($this->db)); if (!is_dir($dir)) { File::mkdir($dir); } $this->dir = $dir . DS . Inflector::urlize(Inflector::uncamelize($this->table)); if (!is_dir($this->dir)) { File::mkdir($this->dir); } $file = $this->dir . DS . 'data.db'; $new = false; if (!is_file($file)) { File::create($file); $new = true; File::put($this->dir . DS . 'age.blizz', ''); } $link = new SQLite3($file); Now::set("blizz.link.{$this->db}.{$this->table}", $link); if ($new) { $this->init(); } }
public function __construct($db = null, $data = []) { $this->storage = $this->initial = $data; if ($db) { $this->db = sha1(get_class($db) . $db->db() . $db->table()); Now::set($this->db, $db); } }
public function remove($hook) { $hooks = Now::get('core.hooks', []); $closure = isAke($hooks, $hook, null); if ($closure) { unset($hooks[$hook]); Now::set('core.hooks', $hooks); return true; } return false; }
public function remove($event) { $events = Now::get('core.events', []); $closure = isAke($events, $event, null); if ($closure) { unset($events[$event]); Now::set('core.events', $events); return true; } return false; }
/** * * @method __construct * * @param string * @param array */ public function __construct($ns = 'core', array $data = []) { $this->ns = $ns; $db = new SQLite3(':memory:'); Now::set("memorylite.link.{$ns}", $db); $q = "CREATE TABLE IF NOT EXISTS cachedb (data_key VARCHAR PRIMARY KEY, data_value);"; $res = $this->db->exec($q); if (!empty($data)) { foreach ($data as $k => $v) { $this->set($k, $v); } } }
public function reset() { $this->results = null; $this->totalResults = 0; $this->transactions = 0; $this->selects = []; $this->joinTables = []; $this->wheres = []; $this->groupBys = []; $this->orders = []; $store = lib('arstore', [$this->collection]); Now::set('ardb.store.' . $this->collection, $store); return $this; }
public function setUser($user) { $users = Now::get('acl.users.' . $this->ns, []); $exists = false; foreach ($users as $u) { if ($u['username'] == $user['username']) { $exists = true; break; } } if (!$exists) { $users[] = $user; } Now::set('acl.users.' . $this->ns, $users); return $this; }
/** * * @method __construct * * @param string * @param array */ public function __construct(array $data = []) { $ns = $this->ns = $this->forever(); $file = Config::get('cachemelite.dir.' . $ns, STORAGE_PATH . DS . $ns . '_cache.db'); $new = !is_file($file); if (!is_file($file)) { File::create($file); } $db = new SQLite3($file); Now::set("cachemelite.link.{$ns}", $db); $q = "CREATE TABLE IF NOT EXISTS cachedb (data_key VARCHAR PRIMARY KEY, data_value);"; $res = $this->db->exec($q); if (!empty($data)) { foreach ($data as $k => $v) { $this->set($k, $v); } } }
public function __construct($db = null, $table = null) { $this->db = is_null($db) ? SITE_NAME : $db; $this->table = is_null($table) ? 'core' : $table; $dir = Config::get('dir.flat.store', session_save_path()); if (!is_dir($dir)) { File::mkdir($dir); } $dir .= DS . Inflector::urlize(Inflector::uncamelize($this->db)); if (!is_dir($dir)) { File::mkdir($dir); } $this->file = $dir . DS . Inflector::urlize(Inflector::uncamelize($this->table)) . '.flat'; if (!file_exists($this->file)) { File::put($this->file, serialize([])); } Now::set('flat.collection.' . $this->db . '.' . $this->table, lib('sessy', [$this->db, $this->table, unserialize(File::read($this->file))])); }
public function __construct($db = null, $table = null) { $this->db = is_null($db) ? SITE_NAME : $db; $this->table = is_null($table) ? 'core' : $table; $dir = Config::get('dir.blizz.store', session_save_path()); if (!is_dir($dir)) { File::mkdir($dir); } $dir .= DS . Inflector::urlize(Inflector::uncamelize($this->db)); if (!is_dir($dir)) { File::mkdir($dir); } $this->dir = $dir . DS . Inflector::urlize(Inflector::uncamelize($this->table)); if (!is_dir($this->dir)) { File::mkdir($this->dir); } $store = lib('blizzstore', [$this]); Now::set("blizz.store.{$this->db}.{$this->table}", $store); $this->cursor = lib('blizzcursor', [$this]); }
public function boot() { $uri = $this->getUri(); list($controllerName, $action, $render) = $this->routes($uri); Now::set('controller', $controllerName); Now::set('action', $action); Now::set('session', session(SITE_NAME)); $controllerFile = Config::get('mvc.dir', APPLICATION_PATH) . DS . 'controllers' . DS . $controllerName . '.php'; if (!is_file($controllerFile)) { $controllerFile = Config::get('mvc.dir', APPLICATION_PATH) . DS . 'controllers' . DS . 'static.php'; $action = 404; } require_once $controllerFile; $class = '\\Thin\\' . ucfirst(strtolower(SITE_NAME)) . ucfirst(Inflector::lower($controllerName)) . 'Controller'; Now::set('request', (new Object())->populate($_REQUEST)); $controller = new $class($action); if (true === $render) { $this->render($controller); } }
public function fn($m, callable $c) { Now::set(str_replace(DS, '.', $this->_db->dir) . '.' . $m, $c); return $this; }
public function __construct($file, $write = null) { $this->file = $file; $this->writeCb = $write; Now::set('remote.collection.' . $this->db . '.' . $this->table, lib('sessy', [$this->db, $this->table, unserialize($this->read($this->file))])); }
function path($k, $v = null, $d = null) { $k = 'helpers.paths.' . $k; if (is_null($v)) { return Now::get($k, $d); } else { return Now::set($k, $v); } }
public function setVar($k, $v = null) { return Now::set($k, $v); }
public function exec() { $method = $this->getMethod(); $routes = []; $found = 0; $routes = isAke($this->routes, $method, []); if (!empty($routes)) { $found = $this->analyze($routes); } if ($found < 1) { if (isset($this->cb404) && is_callable($this->cb404)) { Now::set('page404', true); return call_user_func($this->cb404); } else { header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found'); die; } } else { if ($_SERVER['REQUEST_METHOD'] == 'HEAD') { ob_end_clean(); } return $this->route; } }
public function set($k, $v) { $k = 'flash.' . $k; Now::set($k, $v); return $this; }
/** * [findResto description] * @param array $filter [description] * @param boolean $out [description] * @return [type] [description] */ public function findResto($filter, $out = false) { $collection = $final_plats_dispo = $final_families_plats_dispo = $final_pois_dispo = $final_families_pois_dispo = $final_thematiques_dispo = $final_labels_dispo = $final_activites_dispo = $final_preferences_dispo = $final_specialites_dispo = $final_families_specialites_dispo = $final_types_auto_dispo = $final_types_non_auto_dispo = []; $distanceMin = 999; $distanceMax = 0; $now = time(); $typesAuto = isAke($filter, 'types_auto', []); $typesnonAuto = isAke($filter, 'types_non_auto', []); $food = isAke($filter, 'food', []); $specialities = isAke($filter, 'specialities', []); $suggestions = isAke($filter, 'suggestions', []); $geo = isAke($filter, 'geo', isAke($filter, 'location', [])); $account_id = isAke($filter, 'account_id', 26); $sellzone_id = isAke($filter, 'sellzone_id', 1); $nb_customer = isAke($filter, 'nb_customer', 1); $context = isAke($filter, 'context', 'resto'); $distance = isAke($filter, 'distance', 0); $is_now = isAke($filter, 'now', 0); $mode_conso = isAke($filter, 'mode_conso', 2); $budget = isAke($filter, 'budget', 0); $poi = isAke($filter, 'poi', false); $date = isAke($filter, 'date', date('Y-m-d')); $hour = isAke($filter, 'time', date('H') . ':' . date('i')); $themesFilter = isAke($filter, 'themes', []); list($y, $m, $d) = explode('-', $date); list($h, $i) = explode(':', $hour); $start = mktime($h, $i, 0, $m, $d, $y); $when = lib('time')->createFromTimestamp((int) $start); $jour = $when->frenchDay(); Save::set('filter.' . $this->session_id(), $filter); switch ($context) { case 'all': $father = 'all'; $type_conso = 'sans_reservation'; $distance = 0.5; break; case 'resto': $father = 2165; break; case 'vin': $father = 2026; break; case 'petit_creux': $father = 2164; break; case 'snack': $father = 2164; break; } if (!empty($suggestions)) { $spe_sugg = $auto_sugg = $non_auto_sugg = []; if (count($suggestions) == 1) { $suggs = Model::Suggestion()->where(['segment_id', '=', (int) $suggestions[0]])->cursor(); } else { $suggs = Model::Suggestion()->where(['segment_id', 'IN', implode(',', $suggestions)])->cursor(); } foreach ($suggs as $sugg) { $segs = isAke($sugg, 'segments', []); foreach ($segs as $segSugg) { if (fnmatch('*geo*', $segSugg['type'])) { $spe_sugg[] = (int) $segSugg['id']; } if (fnmatch('*non*', $segSugg['type'])) { $non_auto_sugg[] = (int) $segSugg['id']; } if (fnmatch('*_type*', $segSugg['type'])) { $auto_sugg[] = (int) $segSugg['id']; } } } } // dd($spe_sugg); $optionsMacro = (include APPLICATION_PATH . DS . 'models/options/413.php'); $valuesActivities = array_get($optionsMacro, 'activites.values'); $themes_affil = array_get($optionsMacro, 'activites.types_affil'); /* Thématiques */ $thematiquesResto = array_get($optionsMacro, 'thematiques', []); $thematiquesSnack = array_get($optionsMacro, 'thematiques_snack', []); $thematiquesPc = array_get($optionsMacro, 'thematiques_petit_creux', []); $thematiquesVin = array_get($optionsMacro, 'thematiques_vin', []); $thematiquesModel = []; foreach ($thematiquesResto as $k => $v) { if (fnmatch('*values*', $k)) { $ind = str_replace('values_', '', $k); foreach ($v as $i => $label) { $key = "thematiques_" . $ind . "_{$i}"; $thematiquesModel[$key] = $label; } } } foreach ($thematiquesSnack as $k => $v) { if (fnmatch('*values*', $k)) { $ind = str_replace('values_', '', $k); foreach ($v as $i => $label) { $key = "thematiques_snack_" . $ind . "_{$i}"; $thematiquesModel[$key] = $label; } } } foreach ($thematiquesPc as $k => $v) { if (fnmatch('*values*', $k)) { $ind = str_replace('values_', '', $k); foreach ($v as $i => $label) { $key = "thematiques_petit_creux_" . $ind . "_{$i}"; $thematiquesModel[$key] = $label; } } } foreach ($thematiquesVin as $k => $v) { if (fnmatch('*values*', $k)) { $ind = str_replace('values_', '', $k); foreach ($v as $i => $label) { $key = "thematiques_vin_" . $ind . "_{$i}"; $thematiquesModel[$key] = $label; } } } /* Guides */ $guidesResto = array_get($optionsMacro, 'guides', []); $guidesSnack = array_get($optionsMacro, 'guides_snack', []); $guidesPc = array_get($optionsMacro, 'guides_petit_creux', []); $guidesVin = array_get($optionsMacro, 'guides_vin', []); $guidesModel = []; foreach ($guidesResto as $k => $v) { if (fnmatch('*values*', $k)) { $ind = str_replace('values_', '', $k); foreach ($v as $i => $label) { $key = "guides_" . $ind . "_{$i}"; $guidesModel[$key] = $label; } } } foreach ($guidesSnack as $k => $v) { if (fnmatch('*values*', $k)) { $ind = str_replace('values_', '', $k); foreach ($v as $i => $label) { $key = "guides_snack_" . $ind . "_{$i}"; $guidesModel[$key] = $label; } } } foreach ($guidesPc as $k => $v) { if (fnmatch('*values*', $k)) { $ind = str_replace('values_', '', $k); foreach ($v as $i => $label) { $key = "guides_petit_creux_" . $ind . "_{$i}"; $guidesModel[$key] = $label; } } } foreach ($guidesVin as $k => $v) { if (fnmatch('*values*', $k)) { $ind = str_replace('values_', '', $k); foreach ($v as $i => $label) { $key = "guides_vin_" . $ind . "_{$i}"; $guidesModel[$key] = $label; } } } /* Labels */ $labelsResto = array_get($optionsMacro, 'labels', []); $labelsSnack = array_get($optionsMacro, 'labels_snack', []); $labelsPc = array_get($optionsMacro, 'labels_petit_creux', []); $labelsVin = array_get($optionsMacro, 'labels_vin', []); $labelsModel = []; foreach ($labelsResto as $k => $v) { if (fnmatch('*values*', $k)) { $ind = str_replace('values_', '', $k); foreach ($v as $i => $label) { $key = "labels_" . $ind . "_{$i}"; $labelsModel[$key] = $label; } } } foreach ($labelsSnack as $k => $v) { if (fnmatch('*values*', $k)) { $ind = str_replace('values_', '', $k); foreach ($v as $i => $label) { $key = "labels_snack_" . $ind . "_{$i}"; $labelsModel[$key] = $label; } } } foreach ($labelsPc as $k => $v) { if (fnmatch('*values*', $k)) { $ind = str_replace('values_', '', $k); foreach ($v as $i => $label) { $key = "labels_petit_creux_" . $ind . "_{$i}"; $labelsModel[$key] = $label; } } } foreach ($labelsVin as $k => $v) { if (fnmatch('*values*', $k)) { $ind = str_replace('values_', '', $k); foreach ($v as $i => $label) { $key = "labels_vin_" . $ind . "_{$i}"; $labelsModel[$key] = $label; } } } list($h, $i) = explode(':', $hour, 2); list($y, $m, $d) = explode('-', $date, 3); $ts = mktime($h, $i, 0, $m, $d, $y); $minTime = time() - 1800; if ($ts < $minTime) { return ['total' => 0, 'restaurants' => [], 'specialites_dispo' => [], 'families_specialites_dispo' => [], 'pois_dispo' => [], 'families_pois_dispo' => [], 'preferences_dispo' => [], 'types_auto_dispo' => [], 'types_non_auto_dispo' => [], 'plats_dispo' => [], 'families_plats_dispo' => [], 'labels_dispo' => [], 'thematiques_dispo' => [], 'activites_dispo' => []]; } $mode_conso = $mode_conso == 0 ? 2 : $mode_conso; $last_minute = $is_now > 0; $numberRestos = 0; switch ($mode_conso) { case 1: $type_conso = 'en_livraison'; break; case 2: $type_conso = 'sur_place'; break; case 3: $type_conso = 'a_emporter'; break; case 4: $type_conso = 'sans_reservation'; break; } $sz = Model::Sellzone()->find((int) $sellzone_id); if (!$sz) { $sz = Model::Sellzone()->find(1); } // $lon = isAke($geo, 'lon', (double) $sz->longitude); // $lat = isAke($geo, 'lat', (double) $sz->latitude); $lon = isAke($geo, 'lon', 0); $lat = isAke($geo, 'lat', 0); if (false !== $poi) { $segPoi = Model::Segment()->find($poi); if ($segPoi) { $dataPoi = repo('segment')->getData($poi); $lat = isAke($dataPoi, 'latitude', (double) $sz->latitude); $lon = isAke($dataPoi, 'longitude', (double) $sz->longitude); // $distance = 0; } } $prefs = array_keys($this->extractPreferences($filter)); $labels = array_keys($this->extractLabels($filter)); $thematiques = array_keys($this->extractThematiques($filter)); $activites = array_keys($this->extractActivites($filter)); $cached = false; if ($cached) { return unserialize($cached); } else { $restos = Model::Restodata()->where(['sellzone_id', '=', (int) $sz->id])->cursor(); $ir = []; // $statusZcValid = ['ACTIVE', 'WAITING']; $statusZcValid = ['ACTIVE']; foreach ($restos as $resto) { $reseller_id = isAke($resto, 'reseller_id', false); if (false === $reseller_id) { continue; } $has_favorite = lib('favorite')->has('reseller', $reseller_id, $account_id); $status_zechallenge = isAke($resto, 'status_zechallenge', 'WAITING'); if (!in_array($status_zechallenge, $statusZcValid)) { continue; } if (empty($resto['all_plats'])) { continue; } foreach ($resto['plats']['fathers'] as $idp => $idf) { if ('all' != $father) { if ($idf != $father) { unset($resto['all_plats'][$idp]); } } } $plats_dispo = $thematiques_dispo = $labels_dispo = $activites_dispo = $preferences_dispo = $specialites_dispo = $types_auto_dispo = $types_non_auto_dispo = $choosePlates = []; $ir[$reseller_id] = []; $reseller = Model::Reseller()->model($resto['reseller']); if ($reseller) { Now::set('resto.reseller_id', $reseller->id); $prefsResto = array_keys($this->extractPreferences($resto['options'])); $activitesResto = array_keys($this->extractActivites($resto['options'])); $labelsResto = array_keys($this->extractLabels($resto['options'])); $thematiquesResto = array_keys($this->extractThematiques($resto['options'])); $themes = []; foreach ($resto['options'] as $ko => $vo) { if (fnmatch('thematiques_*', $ko) && 1 == $vo) { if ($context == 'all') { $themes[] = $ko; } else { if ($context == 'resto') { if (!fnmatch('*vin*', $ko) && !fnmatch('*snack*', $ko) && !fnmatch('*petit_creux*', $ko)) { $themes[] = $ko; } } elseif ($context == 'vin') { if (fnmatch('*vin*', $ko)) { $themes[] = $ko; } } elseif ($context == 'snack') { if (fnmatch('*snack*', $ko)) { $themes[] = $ko; } } elseif ($context == 'petit_creux') { if (fnmatch('*petit_creux*', $ko)) { $themes[] = $ko; } } } } } if (!empty($themes)) { $ths = []; foreach ($themes as $th) { $ths[] = isAke($thematiquesModel, $th, $th); } $themes = $ths; } $continue = true; if (!empty($themesFilter)) { foreach ($themesFilter as $tf) { if (!in_array($tf, $themes)) { $continue = false; break; } } } if (!$continue) { continue; } /* Guides */ $guides = []; foreach ($resto['options'] as $ko => $vo) { if (fnmatch('guides_*', $ko) && 1 == $vo) { if ($context == 'all') { $themes[] = $ko; } else { if ($context == 'resto') { if (!fnmatch('*vin*', $ko) && !fnmatch('*snack*', $ko) && !fnmatch('*petit_creux*', $ko)) { $guides[] = $ko; } } elseif ($context == 'vin') { if (fnmatch('*vin*', $ko)) { $guides[] = $ko; } } elseif ($context == 'snack') { if (fnmatch('*snack*', $ko)) { $guides[] = $ko; } } elseif ($context == 'petit_creux') { if (fnmatch('*petit_creux*', $ko)) { $guides[] = $ko; } } } } } if (!empty($guides)) { $ths = []; foreach ($guides as $th) { $ths[] = isAke($guidesModel, $th, $th); } $guides = $ths; } /* Labels */ $labels = []; foreach ($resto['options'] as $ko => $vo) { if (fnmatch('labels_*', $ko) && 1 == $vo) { if ($context == 'all') { $labels[] = $ko; } else { if ($context == 'resto') { if (!fnmatch('*vin*', $ko) && !fnmatch('*snack*', $ko) && !fnmatch('*petit_creux*', $ko)) { $labels[] = $ko; } } elseif ($context == 'vin') { if (fnmatch('*vin*', $ko)) { $labels[] = $ko; } } elseif ($context == 'snack') { if (fnmatch('*snack*', $ko)) { $labels[] = $ko; } } elseif ($context == 'petit_creux') { if (fnmatch('*petit_creux*', $ko)) { $labels[] = $ko; } } } } } if (!empty($labels)) { $ths = []; foreach ($labels as $th) { $ths[] = isAke($guidesModel, $th, $th); } $labels = $ths; } $continueBudget = true; $specialites_dispo = $resto['specialites']['dispos']; $specialites_families_dispo = $resto['specialites']['families']; $types_auto_dispo = $resto['auto']['dispos']; $types_non_auto_dispo = $resto['non_auto']['dispos']; if (!empty($suggestions)) { $continue = false; if (!empty($spe_sugg) && !$continue) { foreach ($spe_sugg as $segsugId) { if (in_array($segsugId, $specialites_dispo) || in_array($segsugId, $specialites_families_dispo)) { $continue = true; break; } } } if (!empty($auto_sugg) && !$continue) { foreach ($auto_sugg as $segsugId) { if (in_array($segsugId, $types_auto_dispo)) { $continue = true; break; } } } if (!empty($non_auto_sugg) && !$continue) { foreach ($non_auto_sugg as $segsugId) { if (in_array($segsugId, $types_non_auto_dispo)) { $continue = true; break; } } } if (!$continue) { continue; } } if (!empty($specialities)) { $continue = true; foreach ($specialities as $idSpe) { if (!in_array($idSpe, $specialites_dispo) && !in_array($idSpe, $specialites_families_dispo)) { $continue = false; break; } } if (!$continue) { continue; } } if (!empty($typesAuto)) { $continue = true; foreach ($typesAuto as $idta) { if (!in_array($idta, $types_auto_dispo)) { $continue = false; break; } } if (!$continue) { continue; } } if (!empty($typesnonAuto)) { $continue = true; foreach ($typesnonAuto as $idta) { if (!in_array($idta, $types_non_auto_dispo)) { $continue = false; break; } } if (!$continue) { continue; } } if (!empty($prefs)) { $continue = true; foreach ($prefs as $prefId) { if (!in_array($prefId, $prefsResto)) { $continue = false; break; } } if (!$continue) { continue; } } if (!empty($context) && $context != 'all') { $continue = false; foreach ($activitesResto as $activiteId) { if (fnmatch('*_*_*', $activiteId)) { continue; } $actFamily = isset($valuesActivities[(int) str_replace('activites_', '', $activiteId)]) ? $valuesActivities[(int) str_replace('activites_', '', $activiteId)] : ''; $contextFamily = isAke($themes_affil, $actFamily, []); foreach ($contextFamily as $contextAct) { if ($contextAct == $context) { $continue = true; break; } } if ($continue) { break; } } if (!$continue) { continue; } } $total_price = 0; if (false !== $poi) { if (!in_array($poi, $resto['pois']['dispos'])) { continue; } else { if ($distance > 0) { $km = $resto['pois']['distances'][$poi]; if ($distance < $km) { continue; } } } } if (!empty($food)) { $choosePlates = $plats_disponibles = $hasId = $hasfamily = $familyPlates = $plats_disponibles = $collectionFoods = []; foreach ($food as $idPlat) { $item = []; $data = repo('segment')->getData((int) $idPlat); $ordre = isAke($data, 'ordre', 1); $item['ordre'] = $ordre; $item['food_id'] = (int) $idPlat; $collectionFoods[] = $item; } $foodcoll = lib('collection', [$collectionFoods])->sortBy('ordre')->toArray(); foreach ($foodcoll as $foodItem) { $idPlat = $foodItem['food_id']; $ordre = $foodItem['ordre']; foreach ($resto['all_plats'] as $tabPlats) { foreach ($tabPlats as $tabPlat) { $assoc = $resto['assocs'][$tabPlat['id']]; $family = $resto['plats']['families']; $isFamily = in_array($idPlat, $family); if ($tabPlat['segment_id'] != $idPlat && !in_array($idPlat, $family)) { continue; } $addPlate = true; $price = (double) $tabPlat['price']; if (0 < $budget && !$isFamily) { if ($price > $budget) { $addPlate = false; } } // if (!empty($specialities) && !$isFamily) { // $specialites_plat = $assoc['geo']; // foreach ($specialities as $idSpe) { // if (!in_array($idSpe, $specialites_plat)) {vd($reseller->id, $idPlat); // $addPlate = false; // break; // } // } // } // if (!empty($typesAuto) && !$isFamily) { // $types_auto_plat = $assoc['auto']; // foreach ($typesAuto as $idta) { // if (!in_array($idta, $types_auto_plat)) { // $addPlate = false; // break; // } // } // } // if (!empty($typesnonAuto) && !$isFamily) { // $types_non_auto_plat = $assoc['non_auto']; // foreach ($typesnonAuto as $idta) { // if (!in_array($idta, $types_non_auto_plat)) { // $addPlate = false; // break; // } // } // } if ($addPlate) { $hasId[$idPlat] = true; if (!$isFamily) { $total_price += (double) $price * $nb_customer; $datasPlat = $resto['datas'][$tabPlat['segment_id']]; $prefix = isAke($datasPlat, 'prefixe', ''); $prefix = strlen($prefix) ? $prefix . ' ' : $prefix; $plate = ['id' => (int) $tabPlat['segment_id'], 'catalog_id' => (int) $tabPlat['id'], 'price' => $price, 'total_price' => $price * $nb_customer, 'catalog_name' => $tabPlat['price'], 'name' => $prefix . $resto['names'][$tabPlat['segment_id']], 'ordre' => $ordre]; $choosePlates[] = $plate; $plate = ['id' => (int) $tabPlat['segment_id'], 'catalog_id' => (int) $tabPlat['id'], 'price' => $price, 'total_price' => $price * $nb_customer, 'catalog_name' => $tabPlat['price'], 'name' => $prefix . $resto['names'][$tabPlat['segment_id']], 'ordre' => $ordre]; $plats_disponibles[] = $plate; } else { if (!isset($familyPlates[$idPlat])) { $familyPlates[$idPlat] = []; } $hasfamily[$idPlat] = true; $platesChildren = redis()->get('getAllchildren.' . $idPlat . '.' . Model::Segment()->getAge()); if (!$platesChildren) { $platesChildren = repo('segment')->getAllchildren(repo('segment')->getChildren($idPlat), $idPlat); redis()->set('getAllchildren.' . $idPlat . '.' . Model::Segment()->getAge(), serialize($platesChildren)); } else { $platesChildren = unserialize($platesChildren); } foreach ($platesChildren as $platechild) { $cisFamily = in_array($platechild['id'], $family); $chas = isset($resto['all_plats'][$platechild['id']]); if (!$cisFamily && $chas) { $infChild = current($resto['all_plats'][$platechild['id']]); $assoc = $resto['assocs'][$infChild['id']]; $addPlateChild = true; $price = (double) $infChild['price']; if (0 < $budget) { if ($price > $budget) { $addPlateChild = false; } } if ($addPlateChild) { if (isset($resto['datas'][$infChild['segment_id']])) { $datasPlat = $resto['datas'][$infChild['segment_id']]; $prefix = isAke($datasPlat, 'prefixe', ''); $prefix = strlen($prefix) ? $prefix . ' ' : $prefix; } else { $prefix = ''; } $plate = ['id' => (int) $infChild['segment_id'], 'catalog_id' => (int) $infChild['id'], 'price' => $price, 'total_price' => $price * $nb_customer, 'catalog_name' => $resto['plats']['catalog_names'][$infChild['id']], 'name' => $prefix . $resto['names'][$infChild['segment_id']]]; $familyPlates[$idPlat][] = $plate; $plats_disponibles[] = $plate; } } } } } } } } $continue = count($food) == count($hasId); if (!$continue) { continue; } else { if (count($hasfamily) == count($food) && (!empty($specialities) || !empty($typesAuto) || !empty($typesnonAuto))) { foreach ($resto['all_plats'] as $tabPlats) { foreach ($tabPlats as $tabPlat) { $assoc = $resto['assocs'][$tabPlat['id']]; $addPlate = true; $price = (double) $tabPlat['price']; if (0 < $budget) { if ($price > $budget) { $addPlate = false; } } // if (!empty($specialities)) { // $specialites_plat = $assoc['geo']; // foreach ($specialities as $idSpe) { // if (!in_array($idSpe, $specialites_plat)) { // $addPlate = false; // break; // } // } // } // if (!empty($typesAuto)) { // $types_auto_plat = $assoc['auto']; // foreach ($typesAuto as $idta) { // if (!in_array($idta, $types_auto_plat)) { // $addPlate = false; // break; // } // } // } // if (!empty($typesnonAuto)) { // $types_non_auto_plat = $assoc['non_auto']; // foreach ($typesnonAuto as $idta) { // if (!in_array($idta, $types_non_auto_plat)) { // $addPlate = false; // break; // } // } // } if ($addPlate) { $plate = ['id' => (int) $tabPlat['segment_id'], 'catalog_id' => (int) $tabPlat['id'], 'price' => $price, 'total_price' => $price * $nb_customer, 'catalog_name' => $resto['plats']['catalog_names'][$tabPlat['id']], 'name' => $resto['names'][$tabPlat['segment_id']]]; $plats_disponibles[] = $plate; } } } } elseif (!empty($suggestions)) { $allSuggestPlates = []; $assocsSuggIds = []; if (!empty($spe_sugg)) { $segs = isAke(isAke($resto, 'specialites', []), 'plats', []); foreach ($spe_sugg as $idta) { $segsPlats = isset($segs[$idta]) ? array_values(array_unique($segs[$idta])) : []; if (!isset($assocsSuggIds[$idta])) { $assocsSuggIds[$idta] = []; } foreach ($segsPlats as $idSuggPlat) { if (!in_array($idSuggPlat, $allSuggestPlates)) { $allSuggestPlates[] = $assocsSuggIds[$idta][] = $idSuggPlat; } } } } if (!empty($auto_sugg)) { $segs = isAke(isAke($resto, 'auto', []), 'plats', []); foreach ($auto_sugg as $idta) { $segsPlats = isset($segs[$idta]) ? array_values(array_unique($segs[$idta])) : []; if (!isset($assocsSuggIds[$idta])) { $assocsSuggIds[$idta] = []; } foreach ($segsPlats as $idSuggPlat) { if (!in_array($idSuggPlat, $allSuggestPlates)) { $allSuggestPlates[] = $assocsSuggIds[$idta][] = $idSuggPlat; } } } } if (!empty($non_auto_sugg)) { $segs = isAke(isAke($resto, 'non_auto', []), 'plats', []); foreach ($non_auto_sugg as $idta) { $segsPlats = isset($segs[$idta]) ? array_values(array_unique($segs[$idta])) : []; if (!isset($assocsSuggIds[$idta])) { $assocsSuggIds[$idta] = []; } foreach ($segsPlats as $idSuggPlat) { if (!in_array($idSuggPlat, $allSuggestPlates)) { $allSuggestPlates[] = $assocsSuggIds[$idta][] = $idSuggPlat; } } } } foreach ($resto['all_plats'] as $tabPlats) { foreach ($tabPlats as $tabPlat) { $addPlate = true; $check = in_array($tabPlat['segment_id'], $allSuggestPlates); if ($check) { $price = (double) $tabPlat['price']; if (0 < $budget) { if ($price > $budget) { $addPlate = false; } } if ($addPlate) { $plate = ['is_suggest' => true, 'id' => (int) $tabPlat['segment_id'], 'catalog_id' => (int) $tabPlat['id'], 'price' => $price, 'total_price' => $price * $nb_customer, 'catalog_name' => $resto['plats']['catalog_names'][$tabPlat['id']], 'name' => $resto['names'][$tabPlat['segment_id']]]; $plats_disponibles[] = $plate; } } // $assoc = $resto['assocs'][$tabPlat['id']]; // $addPlate = false; // $price = (double) $tabPlat['price']; // if (0 < $budget) { // if ($price > $budget) { // $addPlate = false; // } // } // $check = false; // if (!empty($spe_sugg) && !$check) { // $specialites_plat = $assoc['geo']; // foreach ($spe_sugg as $idSpe) { // if (in_array($idSpe, $specialites_plat)) { // $check = true; // $addPlate = true; // break; // } // } // } // if (!empty($auto_sugg) && !$check) { // $types_auto_plat = $assoc['auto']; // foreach ($auto_sugg as $idta) { // if (in_array($idta, $types_auto_plat)) { // $check = true; // $addPlate = true; // break; // } // } // } // if (!empty($non_auto_sugg) && !$check) { // $types_non_auto_plat = $assoc['non_auto']; // $segs = isAke(isAke($resto, 'non_auto', []), 'plats', []); // foreach ($non_auto_sugg as $idta) { // $segsPlats = isset($segs[$idta]) // ? array_values(array_unique($segs[$idta])) // : []; // if (in_array($tabPlat['id'], $segsPlats)) { // $check = true; // $addPlate = true; // break; // } // } // } // if ($addPlate) { // $plate = [ // 'id' => (int) $tabPlat['segment_id'], // 'catalog_id' => (int) $tabPlat['id'], // 'price' => $price, // 'total_price' => $price * $nb_customer, // 'catalog_name' => $resto['plats']['catalog_names'][$tabPlat['id']], // 'name' => $resto['names'][$tabPlat['segment_id']], // ]; // $plats_disponibles[] = $plate; // } } } } } } else { $plats_disponibles = []; foreach ($resto['all_plats'] as $tabPlats) { foreach ($tabPlats as $tabPlat) { // $data = repo('segment')->getData((int) $tabPlat['segment_id']); $data = isAke($tabPlat, 'data', []); $ordre = isAke($data, 'ordre', 1); $assoc = $resto['assocs'][$tabPlat['id']]; $addPlate = true; $price = (double) $tabPlat['price']; if (0 < $budget) { if ($price > $budget) { $addPlate = false; } } if (!empty($specialities)) { $specialites_plat = $assoc['geo']; foreach ($specialities as $idSpe) { if (!in_array($idSpe, $specialites_plat)) { $addPlate = false; break; } } } if (!empty($typesAuto) && $addPlate) { $types_auto_plat = $assoc['auto']; foreach ($typesAuto as $idta) { if (!in_array($idta, $types_auto_plat)) { $addPlate = false; break; } } } if (!empty($typesnonAuto) && $addPlate) { $types_non_auto_plat = $assoc['non_auto']; foreach ($typesnonAuto as $idta) { if (!in_array($idta, $types_non_auto_plat)) { $addPlate = false; break; } } } if ($addPlate) { $plate = ['id' => (int) $tabPlat['segment_id'], 'catalog_id' => (int) $tabPlat['id'], 'price' => $price, 'total_price' => $price * $nb_customer, 'catalog_name' => $tabPlat['price'], 'name' => $resto['names'][$tabPlat['segment_id']], 'ordre' => (int) $ordre]; $plats_disponibles[] = $plate; } } } } $type_conso = 'sans_reservation' == $type_conso ? 'sur_place' : $type_conso; $schedules = isAke($resto['schedules'], $type_conso, []); list($canServe, $service, $last_minute, $fermeMidi, $fermeSoir, $rStock) = $this->checkCanServe((int) $reseller->id, (int) $nb_customer, $schedules, $date, $hour, $resto['options'], $type_conso, $last_minute); if ($canServe) { $jours = isAke($resto, 'jours', []); $services = isAke($resto, 'services', []); $hasAllPrefs = true; $hasAllActivites = true; $locationReseller = isAke($resto, 'loc', ['lng' => 0, 'lat' => 0]); if (0 == $lon && 0 == $lat) { $km = $distanceMin = $distanceMax = 0; } else { if (false !== $lon && false !== $lat) { $distances = distanceKmMiles($lon, $lat, $locationReseller['lng'], $locationReseller['lat']); } else { $distances = distanceKmMiles($sz->longitude, $sz->latitude, $locationReseller['lng'], $locationReseller['lat']); } $km = (double) $distances['km']; if ($km < $distanceMin) { $distanceMin = $km; } if ($km > $distanceMax) { $distanceMax = $km; } } if ($hasAllPrefs && $hasAllActivites) { $checkDistance = true; if (0 < $distance) { $checkDistance = $km <= $distance; } if ($checkDistance) { $activity = null; $activitiesResto = []; if (is_array($activitesResto)) { if (!empty($activitesResto)) { $firstActivite = current($activitesResto); $activity = isset($valuesActivities[(int) str_replace('activites_', '', $firstActivite)]) ? $valuesActivities[(int) str_replace('activites_', '', $firstActivite)] : null; } foreach ($activitesResto as $activiteId) { if (fnmatch('*_*_*', $activiteId)) { continue; } $activitiesResto[] = isset($valuesActivities[(int) str_replace('activites_', '', $activiteId)]) ? $valuesActivities[(int) str_replace('activites_', '', $activiteId)] : ''; } asort($activitiesResto); $activitiesResto = array_values(array_unique($activitiesResto)); $activity = implode(',', $activitiesResto); } $uplifts = $resto['uplifts']; $company = Model::Company()->model($resto['company']); $average_price = isAke($resto, 'average_price', 1); if (!empty($choosePlates)) { $jpds = []; foreach ($choosePlates as $jpd) { $contraintesJour = isset($jours[$jpd['catalog_id']]) ? $jours[$jpd['catalog_id']] : []; $contraintesService = isset($services[$jpd['catalog_id']]) ? $services[$jpd['catalog_id']] : []; $add = true; // if (!empty($contraintesJour)) { // foreach ($contraintesJour as $contrainteJour) { // if ($contrainteJour != $jour) { // $add = false; // break; // } // } // } // if (!empty($contraintesService) && $add) { // foreach ($contraintesService as $contrainteService) { // $contrainteService = (int) $contrainteService; // if ($contrainteService != $service) { // $add = false; // break; // } // } // } if (!empty($contraintesJour)) { $add = in_array($jour, $contraintesJour); } if (!empty($contraintesService) && $add) { $add = in_array($service, $contraintesService); } if ($add) { $jpds[] = $jpd; } } if (empty($jpds)) { continue; } $ocp = $choosePlates = $jpds; $choosePlates = $this->analyzeUplifts($uplifts, $choosePlates, $date, $hour, $nb_customer, $total_price); $composed = isAke($resto, 'composed', []); $hasCompo = false; $composedId = []; if (!empty($composed)) { $newC = []; $c = []; foreach ($composed as $ids => $cmps) { $c[$ids] = []; foreach ($cmps as $cmp) { if ($cmp['type'] == 'entree') { $c[$ids][0][] = ['oldtype' => 'entree', 'type' => 'Entrée', 'name' => $cmp['name']]; } if ($cmp['type'] == 'plat') { $c[$ids][1][] = ['oldtype' => 'plat', 'type' => 'Plat', 'name' => $cmp['name']]; } if ($cmp['type'] == 'fromage') { $c[$ids][2][] = ['oldtype' => 'fromage', 'type' => 'Fromage', 'name' => $cmp['name']]; } if ($cmp['type'] == 'dessert') { $c[$ids][3][] = ['oldtype' => 'dessert', 'type' => 'Dessert', 'name' => $cmp['name']]; } if ($cmp['type'] == 'boisson') { $c[$ids][4][] = ['oldtype' => 'boisson', 'type' => 'Boisson', 'name' => $cmp['name']]; } } ksort($c[$ids]); } $composed = $c; foreach ($choosePlates as $cp) { $segs = isset($composed[$cp['id']]) ? $composed[$cp['id']] : []; if (!empty($segs)) { $composedId[] = $cp['id']; } if (!empty($segs) && !$hasCompo) { $hasCompo = true; } $act = ''; foreach ($segs as $seg) { if (is_array($seg)) { $seg1 = array_shift($seg); $act .= ucfirst($seg1['type']) . ' : ' . $seg1['name'] . ', '; foreach ($seg as $subSeg) { $act .= $subSeg['name'] . ', '; } } } $act = substr($act, 0, -2); $cp['description'] = $act; $newC[] = $cp; } $choosePlates = $newC; $newC = []; $tups = []; foreach ($choosePlates as $cp) { foreach ($composed as $ids => $cmps) { $segs = isset($composed[$cp['id']]) ? $composed[$cp['id']] : []; $menu = []; foreach ($segs as $seg) { if (is_array($seg)) { foreach ($seg as $subSeg) { if (!isset($menu[$subSeg['oldtype']])) { $menu[$subSeg['oldtype']] = []; } $menu[$subSeg['oldtype']][] = $subSeg['name']; } } } } $cp['menu'] = $menu; if (!in_array($cp['id'], $tups)) { $newC[] = $cp; $tups[] = $cp['id']; } } $choosePlates = $newC; } if (!empty($plats_disponibles)) { $jpds = []; foreach ($plats_disponibles as $jpd) { $contraintesJour = isset($jours[$jpd['catalog_id']]) ? $jours[$jpd['catalog_id']] : []; $contraintesService = isset($services[$jpd['catalog_id']]) ? $services[$jpd['catalog_id']] : []; $add = true; // if (!empty($contraintesJour)) { // foreach ($contraintesJour as $contrainteJour) { // if ($contrainteJour != $jour) { // $add = false; // break; // } // } // } // if (!empty($contraintesService) && $add) { // foreach ($contraintesService as $contrainteService) { // $contrainteService = (int) $contrainteService; // if ($contrainteService != $service) { // $add = false; // break; // } // } // } if (!empty($contraintesJour)) { $add = in_array($jour, $contraintesJour); } if (!empty($contraintesService) && $add) { $add = in_array($service, $contraintesService); } if ($add) { $jpds[] = $jpd; } } $plats_disponibles = $jpds; $plats_disponibles = $this->analyzeUplifts($uplifts, $plats_disponibles, $date, $hour, $nb_customer, $total_price); $pds = $tups = []; foreach ($plats_disponibles as $pd) { if (!in_array($pd['id'], $tups)) { $pds[] = $pd; $tups[] = $pd['id']; } } $plats_disponibles = $pds; } if (!empty($familyPlates)) { // dd($choosePlates); foreach ($familyPlates as $idFamily => $tab) { $pprices = []; $item = $tuples = []; $item['id'] = $idFamily; $datasPlat = $resto['datas'][$item['id']]; $prefix = isAke($datasPlat, 'prefixe', ''); $prefix = strlen($prefix) ? $prefix . ' ' : $prefix; $item['name'] = $prefix . $resto['names'][$item['id']]; $item['plats'] = []; $count = 0; foreach ($tab as $ptab) { if (!in_array($ptab['id'], $tuples)) { $count++; $tuples[] = $ptab['id']; $pprices[] = $ptab['price']; $item['plats'][] = $this->infoPlates($resto, $ptab['id']); } } if ($count > 0) { $item['min_price'] = min($pprices); $item['max_price'] = max($pprices); $item['nb'] = $count; // dd($item); $choosePlates[] = $item; } } } if (!empty($specialities)) { foreach ($specialities as $sp) { $pprices = []; $item = $tuples = []; $item['id'] = $sp; $datasPlat = $resto['datas'][$item['id']]; $prefix = isAke($datasPlat, 'prefixe', ''); $prefix = strlen($prefix) ? $prefix . ' ' : $prefix; $item['name'] = $prefix . $resto['names'][$item['id']]; $count = 0; $item['plats'] = []; $platesR = isAke($resto['specialites']['plats'], $sp, []); foreach ($platesR as $platesRId) { $catId = $resto['plats']['catalog'][$platesRId]; $price = $resto['plats']['prices'][$catId]; if (!in_array($platesRId, $tuples)) { $count++; $tuples[] = $platesRId; $pprices[] = $price; $item['plats'][] = $this->infoPlates($resto, $platesRId); } } if ($count > 0) { $item['min_price'] = min($pprices); $item['max_price'] = max($pprices); $item['nb'] = $count; // dd($item); $choosePlates[] = $item; } } } if (!empty($typesAuto)) { foreach ($typesAuto as $sp) { $pprices = []; $item = $tuples = []; $item['id'] = $sp; $datasPlat = $resto['datas'][$item['id']]; $prefix = isAke($datasPlat, 'prefixe', ''); $prefix = strlen($prefix) ? $prefix . ' ' : $prefix; $item['name'] = $prefix . $resto['names'][$item['id']]; $item['plats'] = []; $count = 0; $platesR = isAke($resto['auto']['plats'], $sp, []); foreach ($platesR as $platesRId) { $catId = $resto['plats']['catalog'][$platesRId]; $price = $resto['plats']['prices'][$catId]; if (!in_array($platesRId, $tuples)) { $count++; $tuples[] = $platesRId; $pprices[] = $price; $item['plats'][] = $this->infoPlates($resto, $platesRId); } } if ($count > 0) { $item['min_price'] = min($pprices); $item['max_price'] = max($pprices); $item['nb'] = $count; // dd($item); $choosePlates[] = $item; } } } if (!empty($typesnonAuto)) { foreach ($typesnonAuto as $sp) { $pprices = []; $item = $tuples = []; $item['id'] = $sp; $datasPlat = $resto['datas'][$item['id']]; $prefix = isAke($datasPlat, 'prefixe', ''); $prefix = strlen($prefix) ? $prefix . ' ' : $prefix; $item['name'] = $prefix . $resto['names'][$item['id']]; $item['plats'] = []; $count = 0; $platesR = isAke($resto['non_auto']['plats'], $sp, []); foreach ($platesR as $platesRId) { $catId = $resto['plats']['catalog'][$platesRId]; $price = $resto['plats']['prices'][$catId]; if (!in_array($platesRId, $tuples)) { $count++; $tuples[] = $platesRId; $pprices[] = $price; $item['plats'][] = $this->infoPlates($resto, $platesRId); } } if ($count > 0) { $item['min_price'] = min($pprices); $item['max_price'] = max($pprices); $item['nb'] = $count; // dd($item); $choosePlates[] = $item; } } } $cps = []; $gfs = isAke($resto, 'grandfathers', []); $aps = isAke($resto, 'all_plats', []); $cats = isAke(isAke($resto, 'plats', []), 'catalog', []); $catNames = isAke(isAke($resto, 'plats', []), 'catalog_names', []); foreach ($choosePlates as $cp) { if (!isset($cp['plats']) && in_array($cp['id'], $composedId)) { if (!isset($gfs[$cp['id']])) { $family = repo('segment')->getFamily($cp['id']); $gfs[$cp['id']] = end($family); } if (isset($gfs[$cp['id']])) { $gp = $gfs[$cp['id']]; $idCat = isset($cats[$cp['id']]) ? $cats[$cp['id']] : false; $cn = $gp['name']; if ($idCat) { $cn = isset($catNames[$idCat]) ? $catNames[$idCat] : $cp['name']; } if (!isset($cps[$cp['name']])) { $cps[$cp['name']] = ['nb' => 0, 'min_price' => 1000000, 'max_price' => 0, 'id' => $gp['id'], 'name' => $cp['name'], 'plats' => []]; } $price = $cp['min_price']; $cp['price'] = $price; $cp['catalog_name'] = $cn; $cp['catalog_id'] = $idCat; unset($cp['min_price'], $cp['max_price'], $cp['nb'], $cp['ordre']); $i = isset($aps[$cp['id']]) ? $aps[$cp['id']] : []; if (!empty($i)) { $i = current($i); if (!isset($cp['description'])) { $cp['description'] = isAke($i, 'description', ''); } else { if (empty($cp['description'])) { $cp['description'] = isAke($i, 'description', ''); } } if (!isset($cp['accompagnement'])) { $cp['accompagnement'] = isAke($i, 'accompagnement', ''); } else { if (empty($cp['accompagnement'])) { $cp['accompagnement'] = isAke($i, 'accompagnement', ''); } } } $cps[$cp['name']]['plats'][] = $cp; $cps[$cp['name']]['nb']++; $cps[$cp['name']]['min_price'] = min($cps[$cp['name']]['min_price'], $price); $cps[$cp['name']]['max_price'] = max($cps[$cp['name']]['max_price'], $price); } } else { $cps[$cp['name']] = ['nb' => $cp['nb'], 'min_price' => $cp['min_price'], 'max_price' => $cp['max_price'], 'id' => $cp['id'], 'name' => $cp['name']]; } } $choosePlates = true === $hasCompo ? array_values($cps) : $choosePlates; if (!$hasCompo) { $plats = isAke($resto, 'plats', []); $catalog = isAke($plats, 'catalog', []); $cp = []; foreach ($choosePlates as $cplate) { $hasPlates = isset($cplate['plats']); if ($hasPlates) { $idc = isset($catalog[$cplate['id']]) ? $catalog[$cplate['id']] : false; $description = isset(isAke($resto, 'descriptions', [])[$cplate['id']]) ? isAke($resto, 'descriptions', [])[$cplate['id']] : ''; $accompagnement = isset(isAke($resto, 'accompagnements', [])[$cplate['id']]) ? isAke($resto, 'accompagnements', [])[$cplate['id']] : ''; if (false !== $idc) { $name = isset($plats['catalog_names'][$idc]) ? $plats['catalog_names'][$idc] : $cplate['name']; $cplate['name'] = $cplate['name']; $cplate['catalog_name'] = $name; $cplate['catalog_id'] = $idc; $cplate['description'] = $description; $cplate['accompagnement'] = $accompagnement; } } else { $cplate['plats'] = []; $accompagnements = isAke($resto, 'accompagnements', []); $descriptions = isAke($resto, 'descriptions', []); $prices = $resto['plats']['prices']; foreach ($ocp as $olp) { if ($olp['id'] == $cplate['id']) { $pl = []; $idc = $olp['catalog_id']; $description = isset($descriptions[$idc]) ? $descriptions[$idc] : ''; $accompagnement = isset($accompagnements[$idc]) ? $accompagnements[$idc] : ''; $name = isset($plats['catalog_names'][$idc]) ? $plats['catalog_names'][$idc] : $cplate['name']; $price = isset($prices[$idc]) ? $prices[$idc] : 0; $pl['id'] = $cplate['id']; $pl['name'] = $name; $pl['catalog_name'] = $name; $pl['catalog_id'] = $idc; $pl['description'] = $description; $pl['accompagnement'] = $accompagnement; $pl['price'] = (double) $price; $cplate['plats'][] = $pl; } } } $cp[] = $cplate; } $choosePlates = $cp; $keyCache = sha1($reseller->id . $this->session_id() . 'platschoisis'); redis()->set($keyCache, serialize($cp)); } $conditions_acompte_amount = isAke($resto['options'], 'conditions_acompte_amount', false); $conditions_delai_annulation = isAke($resto['options'], 'conditions_delai_annulation', 24); if ($conditions_acompte_amount) { $conditions_acompte_amount = "{$conditions_acompte_amount} €"; } else { $conditions_acompte_amount = '0 €'; } $conditions_delai_annulation = "{$conditions_delai_annulation} h"; $itemAdd = ['id' => (int) $reseller->id, 'name' => $company->name, 'stock' => $rStock, 'themes' => $themes, 'context' => $context, 'activity' => $activity, 'activities' => $activitiesResto, 'address' => $company->address . ', ' . $company->city, 'city' => $company->city, 'plats_choisis' => $choosePlates, 'plats_ranges' => isAke($resto, 'plats_ranges', []), 'distance' => (int) ($km * 1000), 'last_minute' => $last_minute, 'themes_resto' => isAke($resto, 'themes', []), 'rate' => (double) $resto['rate'], 'has_news' => isAke($resto, 'has_news', false), 'has_myzelift' => isAke($resto, 'has_myzelift', false), 'has_favorite' => $has_favorite, 'conditions_acompte' => isAke($resto['options'], 'conditions_acompte', false), 'conditions_acompte_amount' => $conditions_acompte_amount, 'conditions_delai_annulation' => $conditions_delai_annulation, 'average_price' => $average_price, 'service' => $service]; if (!empty($plats_disponibles)) { $coll = lib('collection', [$plats_disponibles]); $min_price = $coll->min('min_price'); $max_price = $coll->max('max_price'); $nb_plats = $coll->sum('nb'); $ups = $tuplesUp = []; foreach ($plats_disponibles as $tmpRow) { $upliftRow = isAke($tmpRow, 'uplift', false); if (false !== $upliftRow) { if (!is_array($upliftRow)) { if (!in_array($upliftRow['id'], $tuplesUp)) { $ups[] = $upliftRow; $tuplesUp[] = $upliftRow['id']; } } } } $pds = $tups = []; foreach ($plats_disponibles as $pd) { if (!in_array($pd['id'], $tups)) { $pds[] = $pd; $tups[] = $pd['id']; } } if (!empty($suggestions) && !empty($food)) { $ndps = []; foreach ($plats_disponibles as $pdis) { $idPdis = $pdis['id']; foreach ($assocsSuggIds as $idSugg => $arraySugg) { if (!in_array($idPdis, $arraySugg)) { $ndps[] = $pdis; } } } $plats_disponibles = $ndps; if (!empty($spe_sugg)) { foreach ($spe_sugg as $sp) { $pprices = []; $item = $tuples = []; $item['id'] = $sp; $datasPlat = $resto['datas'][$item['id']]; $prefix = isAke($datasPlat, 'prefixe', ''); $prefix = strlen($prefix) ? $prefix . ' ' : $prefix; $item['name'] = $prefix . $resto['names'][$item['id']]; $item['plats'] = []; $count = 0; $platesR = isAke($resto['specialites']['plats'], $sp, []); foreach ($platesR as $platesRId) { $catId = $resto['plats']['catalog'][$platesRId]; $price = $resto['plats']['prices'][$catId]; if (!in_array($platesRId, $tuples)) { $count++; $tuples[] = $platesRId; $pprices[] = $price; $item['plats'][] = $this->infoPlates($resto, $platesRId); } } if ($count > 0) { $item['min_price'] = min($pprices); $item['max_price'] = max($pprices); $item['nb'] = $count; $itemPlates = lib('collection', [isAke($item, 'plats', [])])->sortBy('ordre')->toArray(); $item['plats'] = $itemPlates; $choosePlates[] = $item; } } } if (!empty($auto_sugg)) { foreach ($auto_sugg as $sp) { $pprices = []; $item = $tuples = []; $item['id'] = $sp; $datasPlat = $resto['datas'][$item['id']]; $prefix = isAke($datasPlat, 'prefixe', ''); $prefix = strlen($prefix) ? $prefix . ' ' : $prefix; $item['name'] = $prefix . $resto['names'][$item['id']]; $item['plats'] = []; $count = 0; $platesR = isAke($resto['auto']['plats'], $sp, []); foreach ($platesR as $platesRId) { $catId = $resto['plats']['catalog'][$platesRId]; $price = $resto['plats']['prices'][$catId]; if (!in_array($platesRId, $tuples)) { $count++; $tuples[] = $platesRId; $pprices[] = $price; $item['plats'][] = $this->infoPlates($resto, $platesRId); } } if ($count > 0) { $item['min_price'] = min($pprices); $item['max_price'] = max($pprices); $item['nb'] = $count; $itemPlates = lib('collection', [isAke($item, 'plats', [])])->sortBy('ordre')->toArray(); $item['plats'] = $itemPlates; $choosePlates[] = $item; } } } if (!empty($non_auto_sugg)) { foreach ($non_auto_sugg as $sp) { $pprices = []; $item = $tuples = []; $item['id'] = $sp; $datasPlat = $resto['datas'][$item['id']]; $prefix = isAke($datasPlat, 'prefixe', ''); $prefix = strlen($prefix) ? $prefix . ' ' : $prefix; $item['name'] = $prefix . $resto['names'][$item['id']]; $item['plats'] = []; $count = 0; $platesR = isAke($resto['non_auto']['plats'], $sp, []); foreach ($platesR as $platesRId) { $catId = $resto['plats']['catalog'][$platesRId]; $price = $resto['plats']['prices'][$catId]; if (!in_array($platesRId, $tuples)) { $count++; $tuples[] = $platesRId; $pprices[] = $price; $item['plats'][] = $this->infoPlates($resto, $platesRId); } } if ($count > 0) { $item['min_price'] = min($pprices); $item['max_price'] = max($pprices); $item['nb'] = $count; $itemPlates = lib('collection', [isAke($item, 'plats', [])])->sortBy('ordre')->toArray(); $item['plats'] = $itemPlates; $choosePlates[] = $item; } } } } $itemAdd['plats_disponibles'] = ['nb' => $nb_plats, 'max_price' => $max_price, 'min_price' => $min_price]; if ($nb_plats != count($choosePlates)) { $nc = []; foreach ($choosePlates as $cp) { $nc[] = $cp['id']; $plats = isAke($cp, 'plats', []); if (!empty($plats)) { foreach ($plats as $pl) { $nc[] = $pl['id']; } } } foreach ($plats_disponibles as $tmpRow) { if (!in_array($tmpRow['id'], $nc)) { $i = $this->infoPlates($resto, $tmpRow['id']); $choosePlates[] = ['id' => $tmpRow['id'], 'name' => $tmpRow['name'], 'min_price' => $i['price'], 'max_price' => $i['price'], 'ordre' => isAke($i, 'ordre', 1), 'nb' => isAke($tmpRow, 'nb', 1)]; } } if (!empty($suggestions)) { $choosePlates = $this->analyseSuggestions($choosePlates, $suggestions, $resto); } $c = lib('collection', [$choosePlates])->sortBy('name')->toArray(); $choosePlates = array_values($c); $itemAdd['plats_choisis'] = $choosePlates; $keyCache = sha1($reseller->id . $this->session_id() . 'platschoisis'); redis()->set($keyCache, serialize($choosePlates)); } else { $c = lib('collection', [$choosePlates])->sortBy('name')->toArray(); $choosePlates = array_values($c); $itemAdd['plats_choisis'] = $choosePlates; $keyCache = sha1($reseller->id . $this->session_id() . 'platschoisis'); redis()->set($keyCache, serialize($choosePlates)); } $itemAdd['uplifts'] = isAke(self::$datas, 'uplifts_' . $reseller->id, $ups); } $collection[] = $itemAdd; } else { $jpds = []; foreach ($plats_disponibles as $jpd) { $contraintesJour = isset($jours[$jpd['catalog_id']]) ? $jours[$jpd['catalog_id']] : []; $contraintesService = isset($services[$jpd['catalog_id']]) ? $services[$jpd['catalog_id']] : []; $add = true; if (!empty($contraintesJour)) { $add = in_array($jour, $contraintesJour); } if (!empty($contraintesService) && $add) { $add = in_array($service, $contraintesService); } if ($add) { $jpds[] = $jpd; } } $plats_disponibles = $jpds; $plats_disponibles = $this->analyzeUplifts($uplifts, $plats_disponibles, $date, $hour, $nb_customer, $total_price); if (!empty($specialities)) { foreach ($specialities as $sp) { $spfather = $sp; $pprices = []; $item = $tuples = []; $item['id'] = $sp; $datasPlat = $resto['datas'][$item['id']]; $prefix = isAke($datasPlat, 'prefixe', ''); $prefix = strlen($prefix) ? $prefix . ' ' : $prefix; $spfatherName = $item['name'] = $prefix . $resto['names'][$item['id']]; $item['plats'] = []; $count = 0; $platesR = isAke($resto['specialites']['plats'], $sp, []); if (!empty($platesR)) { foreach ($platesR as $platesRId) { $catId = $resto['plats']['catalog'][$platesRId]; $price = $resto['plats']['prices'][$catId]; if (!in_array($platesRId, $tuples)) { $addplate = true; if (0 < $budget) { $addplate = $budget >= $price; } if ($addplate) { $count++; $tuples[] = $platesRId; $pprices[] = $price; $item['plats'][] = $this->infoPlates($resto, $platesRId); } } } if ($count > 0) { $item['min_price'] = min($pprices); $item['max_price'] = max($pprices); $item['nb'] = $count; $itemPlates = lib('collection', [isAke($item, 'plats', [])])->sortBy('ordre')->toArray(); $item['plats'] = array_values($itemPlates); $choosePlates[] = $item; } } else { $fatherItem = $item; $children = repo('segment')->getAllFamily($sp); foreach ($children as $ch) { $sp = $ch['id']; // $pprices = []; // $item = $tuples = []; // $item['id'] = $sp; // $datasPlat = $resto['datas'][$item['id']]; // $prefix = isAke($datasPlat, 'prefixe', ''); // $prefix = strlen($prefix) ? $prefix . ' ' : $prefix; // $item['name'] = $prefix . $resto['names'][$item['id']]; // $item['plats'] = []; // $count = 0; $platesR = isAke($resto['specialites']['plats'], $sp, []); if (!empty($platesR)) { foreach ($platesR as $platesRId) { $catId = $resto['plats']['catalog'][$platesRId]; $price = $resto['plats']['prices'][$catId]; if (!in_array($catId, $tuples)) { $addplate = true; if (0 < $budget) { $addplate = $budget >= $price; } if ($addplate) { $count++; $tuples[] = $catId; $pprices[] = $price; $item['plats'][] = $this->infoPlates($resto, $platesRId); } } } } } if ($count > 0) { $item['min_price'] = min($pprices); $item['max_price'] = max($pprices); $item['nb'] = $count; $item['father'] = $spfather; $item['father_name'] = $spfatherName; $itemPlates = lib('collection', [isAke($item, 'plats', [])])->sortBy('ordre')->toArray(); $item['plats'] = array_values($itemPlates); $choosePlates[] = $item; } } } } if (empty($choosePlates) && !empty($specialities) && 0 < $budget) { continue; } $suggs = 0; if (!empty($spe_sugg)) { $first = true; foreach ($spe_sugg as $sp) { $pprices = []; $item = $tuples = []; $item['id'] = $sp; $datasPlat = $resto['datas'][$item['id']]; $prefix = isAke($datasPlat, 'prefixe', ''); $prefix = strlen($prefix) ? $prefix . ' ' : $prefix; $item['name'] = $prefix . isAke($resto['names'], $item['id'], ''); $item['plats'] = []; $count = 0; $platesR = isAke($resto['specialites']['plats'], $sp, []); foreach ($platesR as $platesRId) { $catId = $resto['plats']['catalog'][$platesRId]; $price = $resto['plats']['prices'][$catId]; if (!in_array($platesRId, $tuples)) { $count++; $tuples[] = $platesRId; $pprices[] = $price; $item['plats'][] = $this->infoPlates($resto, $platesRId); } } if ($count > 0) { $item['min_price'] = min($pprices); $item['max_price'] = max($pprices); $item['nb'] = $count; $itemPlates = lib('collection', [isAke($item, 'plats', [])])->sortBy('ordre')->toArray(); $item['plats'] = $itemPlates; $choosePlates[] = $item; if ($first) { $suggs++; $first = false; } } } } if (!empty($typesAuto)) { foreach ($typesAuto as $sp) { $pprices = []; $item = $tuples = []; $item['id'] = $sp; $datasPlat = $resto['datas'][$item['id']]; $prefix = isAke($datasPlat, 'prefixe', ''); $prefix = strlen($prefix) ? $prefix . ' ' : $prefix; $item['name'] = $prefix . $resto['names'][$item['id']]; $item['plats'] = []; $count = 0; $platesR = isAke($resto['auto']['plats'], $sp, []); foreach ($platesR as $platesRId) { $catId = $resto['plats']['catalog'][$platesRId]; $price = $resto['plats']['prices'][$catId]; if (!in_array($platesRId, $tuples)) { $count++; $tuples[] = $platesRId; $pprices[] = $price; $item['plats'][] = $this->infoPlates($resto, $platesRId); } } if ($count > 0) { $item['min_price'] = min($pprices); $item['max_price'] = max($pprices); $item['nb'] = $count; $itemPlates = lib('collection', [isAke($item, 'plats', [])])->sortBy('ordre')->toArray(); $item['plats'] = $itemPlates; $choosePlates[] = $item; } } } if (!empty($auto_sugg)) { $first = true; foreach ($auto_sugg as $sp) { $pprices = []; $item = $tuples = []; $item['id'] = $sp; $datasPlat = $resto['datas'][$item['id']]; $prefix = isAke($datasPlat, 'prefixe', ''); $prefix = strlen($prefix) ? $prefix . ' ' : $prefix; $item['name'] = $prefix . $resto['names'][$item['id']]; $item['plats'] = []; $count = 0; $platesR = isAke($resto['auto']['plats'], $sp, []); foreach ($platesR as $platesRId) { $catId = $resto['plats']['catalog'][$platesRId]; $price = $resto['plats']['prices'][$catId]; if (!in_array($platesRId, $tuples)) { $count++; $tuples[] = $platesRId; $pprices[] = $price; $item['plats'][] = $this->infoPlates($resto, $platesRId); } } if ($count > 0) { $item['min_price'] = min($pprices); $item['max_price'] = max($pprices); $item['nb'] = $count; $itemPlates = lib('collection', [isAke($item, 'plats', [])])->sortBy('ordre')->toArray(); $item['plats'] = $itemPlates; $choosePlates[] = $item; if ($first) { $suggs++; $first = false; } } } } if (!empty($non_auto_sugg)) { $first = true; foreach ($non_auto_sugg as $sp) { $pprices = []; $item = $tuples = []; $item['id'] = $sp; $datasPlat = $resto['datas'][$item['id']]; $prefix = isAke($datasPlat, 'prefixe', ''); $prefix = strlen($prefix) ? $prefix . ' ' : $prefix; $item['name'] = $prefix . $resto['names'][$item['id']]; $item['plats'] = []; $count = 0; $platesR = isAke($resto['non_auto']['plats'], $sp, []); foreach ($platesR as $platesRId) { $catId = $resto['plats']['catalog'][$platesRId]; $price = $resto['plats']['prices'][$catId]; if (!in_array($platesRId, $tuples)) { $count++; $tuples[] = $platesRId; $pprices[] = $price; $item['plats'][] = $this->infoPlates($resto, $platesRId); } } if ($count > 0) { $item['min_price'] = min($pprices); $item['max_price'] = max($pprices); $item['nb'] = $count; $itemPlates = lib('collection', [isAke($item, 'plats', [])])->sortBy('ordre')->toArray(); $item['plats'] = $itemPlates; $choosePlates[] = $item; if ($first) { $suggs++; $first = false; } } } } if (!empty($typesnonAuto)) { foreach ($typesnonAuto as $sp) { $pprices = []; $item = $tuples = []; $item['id'] = $sp; $datasPlat = $resto['datas'][$item['id']]; $prefix = isAke($datasPlat, 'prefixe', ''); $prefix = strlen($prefix) ? $prefix . ' ' : $prefix; $item['name'] = $prefix . $resto['names'][$item['id']]; $item['plats'] = []; $count = 0; $platesR = isAke($resto['non_auto']['plats'], $sp, []); foreach ($platesR as $platesRId) { $catId = $resto['plats']['catalog'][$platesRId]; $price = $resto['plats']['prices'][$catId]; if (!in_array($platesRId, $tuples)) { $count++; $tuples[] = $platesRId; $pprices[] = $price; $item['plats'][] = $this->infoPlates($resto, $platesRId); } } if ($count > 0) { $item['min_price'] = min($pprices); $item['max_price'] = max($pprices); $item['nb'] = $count; $itemPlates = lib('collection', [isAke($item, 'plats', [])])->sortBy('ordre')->toArray(); $item['plats'] = array_values($itemPlates); $choosePlates[] = $item; } } } if (!empty($familyPlates)) { foreach ($familyPlates as $idFamily => $tab) { $pprices = []; $item = $tuples = []; $item['id'] = $idFamily; $datasPlat = $resto['datas'][$item['id']]; $prefix = isAke($datasPlat, 'prefixe', ''); $prefix = strlen($prefix) ? $prefix . ' ' : $prefix; $item['name'] = $prefix . $resto['names'][$item['id']]; $item['plats'] = []; $count = 0; foreach ($tab as $ptab) { if (!in_array($ptab['id'], $tuples)) { $count++; $tuples[] = $ptab['id']; $pprices[] = $ptab['price']; $item['plats'][] = $this->infoPlates($resto, $ptab['id']); } } if ($count > 0) { $item['min_price'] = min($pprices); $item['max_price'] = max($pprices); $item['nb'] = $count; $itemPlates = lib('collection', [isAke($item, 'plats', [])])->sortBy('ordre')->toArray(); $item['plats'] = array_values($itemPlates); $choosePlates[] = $item; } } } if (!empty($plats_disponibles)) { $pds = $tups = []; foreach ($plats_disponibles as $pd) { if (!in_array($pd['id'], $tups)) { $pds[] = $pd; $tups[] = $pd['id']; } } $plats_disponibles = $pds; $coll = lib('collection', [$plats_disponibles]); $min_price = $coll->min('min_price'); $max_price = $coll->max('max_price'); $nb_plats = $coll->sum('nb'); $ups = $tuplesUp = []; foreach ($plats_disponibles as $tmpRow) { $upliftRow = isAke($tmpRow, 'uplift', false); if (false !== $upliftRow) { if (!in_array($upliftRow['id'], $tuplesUp)) { $ups[] = $upliftRow; $tuplesUp[] = $upliftRow['id']; } } } $conditions_acompte_amount = isAke($resto['options'], 'conditions_acompte_amount', false); $conditions_delai_annulation = isAke($resto['options'], 'conditions_delai_annulation', 24); if ($conditions_acompte_amount) { $conditions_acompte_amount = "{$conditions_acompte_amount} €"; } else { $conditions_acompte_amount = '0 €'; } $conditions_delai_annulation = "{$conditions_delai_annulation} h"; $item = ['id' => (int) $reseller->id, 'name' => $company->name, 'address' => $company->address . ', ' . $company->city, 'city' => $company->city, 'plats_ranges' => isAke($resto, 'plats_ranges', []), 'plats_disponibles' => ['nb' => $nb_plats, 'max_price' => $max_price, 'min_price' => $min_price], 'uplifts' => isAke(self::$datas, 'uplifts_' . $reseller->id, $ups), 'last_minute' => $last_minute, 'rate' => (double) $resto['rate'], 'average_price' => isAke($resto, 'average_price', 1), 'themes_resto' => isAke($resto, 'themes', []), 'has_news' => isAke($resto, 'has_news', false), 'has_myzelift' => isAke($resto, 'has_myzelift', false), 'has_favorite' => $has_favorite, 'conditions_acompte' => isAke($resto['options'], 'conditions_acompte', false), 'conditions_acompte_amount' => $conditions_acompte_amount, 'conditions_delai_annulation' => $conditions_delai_annulation, 'context' => $context, 'themes' => $themes, 'activity' => $activity, 'activities' => $activitiesResto, 'service' => $service, 'stock' => $rStock, 'distance' => (int) ($km * 1000)]; $addItem = true; if (!empty($suggestions) && empty($food)) { $addItem = $suggs == count($suggestions); } if (!empty($choosePlates)) { if (!empty($suggestions)) { $choosePlates = $this->analyseSuggestions($choosePlates, $suggestions, $resto); } $item['plats_choisis'] = $choosePlates; $keyCache = sha1($reseller->id . $this->session_id() . 'platschoisis'); redis()->set($keyCache, serialize($choosePlates)); } if ($addItem) { $collection[] = $item; } } } $numberRestos++; $ir[$reseller_id]['all_plats'] = $resto['all_plats']; $ir[$reseller_id]['labels'] = $labels; $ir[$reseller_id]['guides'] = $guides; $ir[$reseller_id]['thematiques'] = $thematiquesResto; $ir[$reseller_id]['preferences'] = $prefsResto; $ir[$reseller_id]['activites'] = $activitesResto; foreach ($labels as $labelResto) { if (!in_array($labelResto, $final_labels_dispo)) { $final_labels_dispo[] = $labelResto; } } foreach ($themes as $thematiqueResto) { if (!in_array($thematiqueResto, $final_thematiques_dispo)) { $final_thematiques_dispo[] = $thematiqueResto; } } foreach ($prefsResto as $pr) { if (!in_array($pr, $final_preferences_dispo)) { $final_preferences_dispo[] = $pr; } } foreach ($activitesResto as $id) { if (!in_array($id, $final_activites_dispo)) { $final_activites_dispo[] = $id; } } $ir[$reseller_id]['activities'] = $activitiesResto; $ir[$reseller_id]['types_auto'] = $resto['auto']['dispos']; $ir[$reseller_id]['types_non_auto'] = $resto['non_auto']['dispos']; $ir[$reseller_id]['specialites'] = $resto['specialites']['dispos']; $ir[$reseller_id]['specialites_families'] = $resto['specialites']['families']; $ir[$reseller_id]['plats_families'] = $resto['plats']['families']; $ir[$reseller_id]['pois'] = $resto['pois']['dispos']; $ir[$reseller_id]['pois_families'] = $resto['pois']['families']; $ir[$reseller_id]['plats_catalog'] = array_keys($resto['plats']['catalog']); $final_types_auto_dispo = array_merge($final_types_auto_dispo, $resto['auto']['dispos']); $final_types_non_auto_dispo = array_merge($final_types_non_auto_dispo, $resto['non_auto']['dispos']); $final_specialites_dispo = array_merge($final_specialites_dispo, $resto['specialites']['dispos']); $final_pois_dispo = array_merge($final_pois_dispo, $resto['pois']['dispos']); $final_families_pois_dispo = array_merge($final_families_pois_dispo, $resto['pois']['families']); $final_plats_dispo = array_merge($final_plats_dispo, array_keys($resto['plats']['catalog'])); self::$datas['plats_' . $reseller_id] = array_values(array_unique(array_keys($resto['plats']['catalog']))); $final_families_plats_dispo = array_merge($final_families_plats_dispo, $resto['plats']['families']); $final_families_specialites_dispo = array_merge($final_families_specialites_dispo, $resto['specialites']['families']); } } } } } if ($out) { $collection = array_values(lib('collection', [$collection])->sortBy('distance')->toArray()); $sid = $this->session_id(); if (!isset($service)) { $service = 1; } Save::setExpire('offer.in.' . $filter['account_id'] . '.' . $sid, serialize(['jour' => $jour, 'service' => $service, 'filter' => $filter, 'restaurants' => $collection]), 24 * 3600); Save::setExpire('infos.data.resto.' . $account_id . '.' . $sid, serialize($ir), 24 * 3600); return ['restaurants' => $collection, 'distances' => ['min' => (int) ($distanceMin * 1000), 'max' => (int) ($distanceMax * 1000)]]; } $results = ['total' => count($collection), 'distances' => ['min' => (int) ($distanceMin * 1000), 'max' => (int) ($distanceMax * 1000)], 'restaurants' => $collection, 'pois_dispo' => array_values(array_unique($final_pois_dispo)), 'families_pois_dispo' => array_values(array_unique($final_families_pois_dispo)), 'specialites_dispo' => array_values(array_unique($final_specialites_dispo)), 'families_specialites_dispo' => array_values(array_unique($final_families_specialites_dispo)), 'preferences_dispo' => array_values(array_unique($final_preferences_dispo)), 'types_auto_dispo' => array_values(array_unique($final_types_auto_dispo)), 'types_non_auto_dispo' => array_values(array_unique($final_types_non_auto_dispo)), 'plats_dispo' => array_values(array_unique($final_plats_dispo)), 'families_plats_dispo' => array_values(array_unique($final_families_plats_dispo)), 'labels_dispo' => array_values(array_unique($final_labels_dispo)), 'thematiques_dispo' => array_values(array_unique($final_thematiques_dispo)), 'activites_dispo' => array_values(array_unique($final_activites_dispo))]; // redis()->set($keyCache, serialize($results)); // redis()->expire($keyCache, 120); return $results; } }