public function offreout($reseller_id) { $collection = []; $advices = Model::Advice()->where(['table', '=', 'offreout'])->where(['reseller_id', '=', (int) $reseller_id])->where(['created_at', '>', strtotime(Config::get('advice.maxperiod', '-3 month'))])->cursor(); foreach ($advices as $advice) { $account = Model::Account()->find((int) $advice['account_id']); if ($account) { $row = []; $row['id'] = $advice['id']; $row['positive'] = $advice['positive']; $row['negative'] = $advice['negative']; $row['account_id'] = $account->id; $row['firstname'] = $account->firstname; $rates = Model::Advicerate()->where(['advice_id', '=', (int) $advice['id']])->cursor(); $row['rates'] = []; foreach ($rates as $rate) { $category = Model::Adviceratecategory()->find((int) $rate['adviceratecategory_id']); if ($category) { $row['rates'][] = ['rate' => $rate['rate'], 'name' => $category['name'], 'order' => $category['order'], 'ponderation' => $category['ponderation']]; } } if (!empty($row['rates'])) { $row['rates'] = array_values(lib('collection', [$row['rates']])->sortBy('order')->toArray()); } $collection[] = $row; } } // return $collection; return empty($collection) ? [['id' => 1, 'account_id' => 28, 'firstname' => 'Pierre-Emmanuel', 'positive' => "Un accueil digne d'un 4 étoiles.", 'negative' => "Ma table était en plein courant d'air. Pas de pain en rab...", 'rates' => [['name' => 'Qualité', 'rate' => 6, 'ponderation' => 1], ['name' => 'Accueil', 'rate' => 8, 'ponderation' => 1], ['name' => 'Service', 'rate' => 8, 'ponderation' => 1]]], ['id' => 2, 'account_id' => 30, 'firstname' => 'Nicolas', 'positive' => "Très bon sommelier.", 'negative' => "Pas de parking à proximité.", 'rates' => [['name' => 'Qualité', 'rate' => 8, 'ponderation' => 1], ['name' => 'Accueil', 'rate' => 10, 'ponderation' => 1], ['name' => 'Service', 'rate' => 6, 'ponderation' => 1]]]] : $collection; }
public function create($args) { $points = isAke($args, 'points', false); if (false === $points) { $args['points'] = 0; } return Model::Account()->create($args)->save(); }
public function userModel() { $user = session('log')->getUser(); if (!$user) { return $this->identify()->user(); } if ($user['accounted']) { return Model::Account()->find($user['id']); } else { return Model::Visitor()->find($user['id']); } }