function isExpert() { $repo = $this->requireRepository(); $user = $this->getConnectedUser(); $expert = $this->Expert->find('first', array('conditions' => array('repository_id' => $repo['Repository']['id'], 'user_id' => $user['User']['id']), 'recursive' => -1)); if (empty($expert)) { return false; } return true; }
public function adminSection() { $adminId = Session::get('admin_id'); if (!isset($adminId)) { return Redirect::to('/'); } $expertCount = Expert::where('status', '=', 'active')->count(); $patientCount = Patient::where('status', '=', 'active')->count(); return View::make('admin.admin-section')->with('expertCount', $expertCount)->with('patientCount', $patientCount); }
function getCategoryExperts($id) { if (isset($id)) { $experts = Expert::whereIn('id', function ($query) use($id) { $query->select('expert_id')->from('expert_categories')->where('category_id', $id)->where('status', 'active'); })->get(); if (isset($experts) && count($experts) > 0) { return json_encode(array('message' => 'found', 'experts' => $experts->toArray())); } else { return json_encode(array('message' => 'empty')); } } else { return json_encode(array('message' => 'invalid')); } }
function dataGetExpert($id) { $expert = Expert::find($id); return $expert; }
function dataInstituteExperts($id) { if (isset($id)) { $experts = Expert::where('institute_id', '=', $id)->get(); } else { $institute_id = Session::get('institute_id'); if (!isset($institute_id)) { return 'not logged'; } $experts = Expert::where('institute_id', '=', $institute_id)->get(); } if (isset($experts)) { return json_encode(array('message' => 'found', 'experts' => $experts)); } else { return json_encode(array('message' => 'empty')); } }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param Expert $value A Expert object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(Expert $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null self::$instances[$key] = $obj; } }
/** * @author: jason * @date: 2010-12-15下午01:51:35 * @todo: 获得专家列表 * @params: */ public function getExpertList($limit = 5) { $expert_list = array(); $expert_cate = Expert::model()->getCateList(); // 先判断是否存在缓存,从缓存读取数据 $model = new Expert(); $key = $model->getExpertListCacheKey(); $resource = Yii::app()->cache->get($key); if ($resource === false) { $connection = Yii::app()->db; $sql = " SELECT * FROM {{main_expert}} where is_delete = '0' and status= '1' ORDER BY is_top desc,sort desc LIMIT {$limit} "; $command = $connection->createCommand($sql); $resource = $command->queryAll(); // 设置缓存 Yii::app()->cache->set($key, $resource); } if (!empty($resource)) { foreach ($resource as $one) { $id = $one['expert_id']; $expert_list[$id] = $one; $expert_list[$id]['cate'] = $expert_cate[$one['cate_id']]; $expert_list[$id]['expert_intro'] = cutString($one['expert_intro'], 26); $model = new Show(); $blog_link = $model->createCommendUrl('', 'home', $one['uid']); $expert_list[$id]['blog_link'] = empty($one['blog_link']) ? $blog_link : $one['blog_link']; } } return $expert_list; }
public function sendExpertPassword() { $email = Input::get('email'); $expert = Expert::where('Expert.email', '=', $email)->first(); $data = array('name' => $expert->name); Mail::send('emails.expert-reset-password', $data, function ($message) use($expert) { $message->to($expert->email, $expert->name)->subject('You requested your password'); }); }
public function searchByKeyword($key, $cityId = null) { if (isset($key)) { if (isset($cityId)) { $experts = Expert::where('first_name', 'like', '%' . $key . '%')->Orwhere('last_name', 'like', '%' . $key . '%')->where('status', '=', 'active')->get(); $institutes = Institute::where('name', 'like', '%' . $key . '%')->where('status', '=', 'active')->get(); } else { $experts = Expert::where('first_name', 'like', '%' . $key . '%')->Orwhere('last_name', 'like', '%' . $key . '%')->where('status', '=', 'active')->get(); $institutes = Institute::where('name', 'like', '%' . $key . '%')->where('status', '=', 'active')->get(); } $data = array(); if (isset($experts) && count($experts) > 0) { foreach ($experts as $expert) { $data[] = array('id' => $expert->id, 'name' => $expert->first_name . ' ' . $expert->last_name, 'group' => 'Experts'); } } if (isset($institutes) && count($institutes) > 0) { foreach ($institutes as $institute) { $data[] = array('id' => $institute->id, 'name' => $institute->name, 'group' => 'Institutes'); } } if (isset($data) && count($data) > 0) { return json_encode(array('message' => 'found', 'data' => $data)); } else { return json_encode(array('message' => 'empty')); } } else { return json_encode(array('message' => 'invalid')); } }