本文整理汇总了PHP中Manager::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Manager::find方法的具体用法?PHP Manager::find怎么用?PHP Manager::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Manager
的用法示例。
在下文中一共展示了Manager::find方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
$input = Input::all();
$rules = array('id' => 'required|unique:managers,id,' . $id, 'manager' => 'required', 'email' => 'email|required');
$messages = array('id.required' => 'Please enter manger ID', 'id.unique' => 'This manager ID has already been taken ! Please try an other one ', 'manager.required' => 'Please enter manger name', 'email.required' => 'We need to know your email address !', 'email.email' => 'Please enter a valid email address !', 'username.required' => 'Please enter a Username', 'username.unique' => 'The username has already been taken. Please enter an other one !');
$validation = Validator::make($input, $rules, $messages);
if ($validation->passes()) {
$this->manager = Manager::find($id);
$this->manager->id = Input::get('id');
$this->manager->manager = Input::get('manager');
$this->manager->save();
$this->user->first_name = Input::get('manager');
$this->user->username = Input::get('username');
$this->user->email = Input::get('email');
$this->user->role = 'manager';
$this->user->manager_id = Input::get('id');
$this->user->password = Hash::make(Input::get('password'));
//$this->manager->users()->save($this->user);
DB::table('users')->where('username', $this->user->username)->update(array('email' => $this->user->email, 'first_name' => $this->user->first_name));
return Redirect::to('/managers');
} else {
//print_r($id);
//exit;
return Redirect::to('/managers/' . $id . '/edit')->withErrors($validation);
}
}
示例2: managerusernamecheckAction
public function managerusernamecheckAction()
{
$this->view->disable();
$username = $this->request->getPost('username', 'string');
$id = $this->request->getPost('id', 'int');
$manager_exits = Manager::find(array("username = :username:", 'bind' => array('username' => $username)));
if (count($manager_exits) == 1) {
#存在
foreach ($manager_exits as $manager) {
if ($manager->project_id == $id) {
$this->dataReturn(array('flag' => false));
return;
}
}
$this->dataReturn(array('flag' => true));
return;
} else {
$this->dataReturn(array('flag' => false));
return;
}
}
示例3: listleaderAction
public function listleaderAction()
{
$this->view->disable();
$manager = $this->session->get('Manager');
if (empty($manager)) {
$this->dataReturn(array('error' => '获取用户信息失败,请重新登陆'));
return;
}
$project_id = $manager->project_id;
$page = $this->request->get('page');
$rows = $this->request->get('rows');
$offset = $rows * ($page - 1);
$limit = $rows;
$sidx = $this->request->getQuery('sidx', 'string');
$sord = $this->request->getQuery('sord', 'string');
if ($sidx != null) {
$sort = $sidx;
} else {
$sort = 'id';
$sord = 'desc';
}
if ($sord != null) {
$sort = $sort . ' ' . $sord;
}
//default get
$search_state = $this->request->get('_search');
if ($search_state == 'false') {
$result = $this->modelsManager->createBuilder()->columns(array('Manager.id as id', 'Manager.username as username', 'Manager.name as name', 'Manager.password as password', 'Manager.last_login as last_login'))->from('Manager')->where('Manager.project_id = ' . $project_id . " AND Manager.role = 'L'")->limit($limit, $offset)->orderBy($sort)->getQuery()->execute();
$rtn_array = array();
$interviewers = Manager::find(array('project_id=?1 AND role = ?2', 'bind' => array(1 => $project_id, 2 => 'L')));
//获取该项目下答题的总人数
$count = count($interviewers);
$rtn_array['total'] = ceil($count / $rows);
$rtn_array['records'] = $count;
// $rtn_array['rows'] = $result;
foreach ($result as $value) {
$rtn_array['rows'][] = $value;
}
$rtn_array['page'] = $page;
$this->dataReturn($rtn_array);
return;
} else {
//处理search情况
$search_field = $this->request->get('searchField');
$search_string = $this->request->get('searchString');
$search_oper = $this->request->get('searchOper');
if ($search_field == 'username') {
$filed = 'Manager.' . $search_field;
$oper = '=';
$value = $search_string;
} else {
if ($search_field == 'name') {
$filed = 'Manager.' . $search_field;
$oper = 'LIKE';
$value = '%' . $search_string . '%';
} else {
if ($search_field == 'last_login') {
$filed = 'Manager.' . $search_field;
if ($search_oper == 'bw') {
$oper = '>=';
} else {
if ($search_oper == 'ew') {
$oper = '<=';
}
}
$value = $search_string;
} else {
//..
return;
}
}
}
$result = $this->modelsManager->createBuilder()->columns(array('Manager.id as id', 'Manager.username as username', 'Manager.name as name', 'Manager.password as password', 'Manager.last_login as last_login'))->from('Manager')->where('Manager.project_id = ' . $project_id . " AND Manager.role = 'L' AND {$filed} {$oper} '{$value}'")->limit($limit, $offset)->orderBy($sort)->getQuery()->execute();
$rtn_array = array();
$interviewers = Manager::find(array('project_id=?1 AND role = ?2', 'bind' => array(1 => $project_id, 2 => 'L')));
//获取该项目下答题的总人数
$count = count($interviewers);
$rtn_array['total'] = ceil($count / $rows);
$rtn_array['records'] = $count;
// $rtn_array['rows'] = $result;
foreach ($result as $value) {
$rtn_array['rows'][] = $value;
}
$rtn_array['page'] = $page;
$this->dataReturn($rtn_array);
return;
}
}
示例4: find
/**
* @param $uri
*
* @return Resource
*/
public function find($uri)
{
/** @var \EasyRdf_Sparql_Result $result */
$result = $this->_rm->find($uri, $this->className);
return $result;
}
示例5: deleteManager
public function deleteManager($id)
{
if (Session::has('username') && Session::get('user_type') == "Root") {
if (!is_numeric($id) || !Manager::find($id)) {
redirect("settings/employees/managers");
}
$manager = Manager::find($id);
$desc = "(" . Session::get('user_type') . ") " . "<strong>" . Session::get('username') . "</strong> has deleted manager <strong>" . $manager->first_name . " " . $manager->last_name . "</strong>.";
//Log the changes made
$newLog = new UserLog();
$newLog->description = $desc;
$newLog->user_id = Session::get('user_id');
$newLog->type = "System";
$newLog->save();
$manager->delete();
return Redirect::to("settings/employees/managers");
} else {
redirect("/");
}
}
示例6: find
/**
* @param mixed $id
* @return object|NULL
*/
public function find($id)
{
// TODO solve possibility to call with more column in primary key
return $this->manager->find($this->classMetadata->getEntityName(), $id);
}
示例7: processImport
//.........这里部分代码省略.........
if ($validator->messages()->get("email")) {
foreach ($validator->messages()->get("email") as $e) {
$errorCount += 1;
$error[$rowIndex][$errorCount] = $errorCount . ". " . $e . "<br/>";
}
}
if ($validator->messages()->get("status")) {
foreach ($validator->messages()->get("status") as $e) {
$errorCount += 1;
$error[$rowIndex][$errorCount] = $errorCount . ". " . $e . "<br/>";
}
}
}
if (!preg_match('/^[\\pL.-\\s]+$/u', $r->firstname) || !preg_match('/^[\\pL.-\\s]+$/u', $r->lastname)) {
$hasError = true;
//This will only matter if no errors has been found above.
$rowHasError = true;
//This will only matter if no errors has been found above.
$rowsWithErrors[$rowIndex] = $rowIndex;
//This will only matter if no errors has been found above.
$errorCount += 1;
$error[$rowIndex][$errorCount] = $errorCount . ". " . "First name/last name fields must only contain alphabetic characters and whitespaces." . "<br/>";
}
if (!is_numeric($r->manager)) {
$hasError = true;
//This will only matter if no errors has been found above.
$rowHasError = true;
//This will only matter if no errors has been found above.
$rowsWithErrors[$rowIndex] = $rowIndex;
//This will only matter if no errors has been found above.
$errorCount += 1;
$error[$rowIndex][$errorCount] = $errorCount . ". " . "Manager ID should be numeric." . "<br/>";
}
if (is_numeric($r->manager) && !Manager::find($r->manager)) {
$hasError = true;
//This will only matter if no errors has been found above.
$rowHasError = true;
//This will only matter if no errors has been found above.
$rowsWithErrors[$rowIndex] = $rowIndex;
//This will only matter if no errors has been found above.
$errorCount += 1;
$error[$rowIndex][$errorCount] = $errorCount . ". " . "Invalid manager ID." . "<br/>";
}
if (empty(trim($r->nsnid)) && !in_array(strtolower($r->status), array("academy", "ojt", "contractual", "graduate", "obsolete"))) {
$hasError = true;
//This will only matter if no errors has been found above.
$rowHasError = true;
//This will only matter if no errors has been found above.
$rowsWithErrors[$rowIndex] = $rowIndex;
//This will only matter if no errors has been found above.
$errorCount += 1;
$error[$rowIndex][$errorCount] = $errorCount . ". " . "The NSN ID is required." . "<br/>";
}
if (!empty($r->nsnid) && !is_numeric(trim($r->nsnid)) && !in_array($r->status, array("academy", "ojt", "contractual", "graduate", "obsolete"))) {
$hasError = true;
//This will only matter if no errors has been found above.
$rowHasError = true;
//This will only matter if no errors has been found above.
$rowsWithErrors[$rowIndex] = $rowIndex;
//This will only matter if no errors has been found above.
$errorCount += 1;
$error[$rowIndex][$errorCount] = $errorCount . ". " . "The NSN ID should be numeric." . "<br/>";
}
if (!empty($r->nsnid) && Employee::where("nsn_id", "=", $r->nsnid)->first()) {
$hasError = true;
//This will only matter if no errors has been found above.
示例8: exportroleAction
public function exportroleAction($type)
{
$manager = $this->session->get('Manager');
if (empty($manager)) {
$this->dataReturn(array('error' => '用户信息失效,请重新登录!'));
return;
}
try {
$excelExport = new ExcelExport();
$file_name = '';
switch ($type) {
case 1:
$result = Examinee::find(array('project_id = ?1 AND type = 0 ', 'bind' => array(1 => $manager->project_id)));
$file_name = $excelExport->ExamineeExport($result, $manager->project_id);
$this->dataReturn(array('success' => $file_name));
return;
break;
case 2:
$result = Manager::find(array('project_id = ?1 AND role = \'I\'', 'bind' => array(1 => $manager->project_id)));
$file_name = $excelExport->InterviewerExport($result, $manager->project_id);
$this->dataReturn(array('success' => $file_name));
return;
break;
case 3:
$result = Manager::find(array('project_id = ?1 AND role = \'L\'', 'bind' => array(1 => $manager->project_id)));
$file_name = $excelExport->LeaderExport($result, $manager->project_id);
$this->dataReturn(array('success' => $file_name));
return;
break;
default:
$this->dataReturn(array('error' => '参数错误-' . $type));
return;
}
} catch (Exception $e) {
$this->dataReturn(array('error' => '列表生成失败'));
return;
}
}
示例9: insertInterviewer
public static function insertInterviewer($data, $project_id)
{
//对原有数据整理
$interviewer = Manager::find(array('project_id =?0 and role=?1', "order" => "username desc", 'bind' => array(0 => $project_id, 1 => 'I')));
$new_count = count($data);
//1501 101
$already_number = 0;
if (count($interviewer) == 0) {
$already_number = 0;
} else {
$already_number = $interviewer[0]->username - $project_id * 1000 - 100;
}
#异常
if ($new_count + $already_number > 99) {
throw new Exception('项目人数超限-99');
}
$start = $project_id * 1000 + 100 + $already_number + 1;
try {
$manager = new TxManager();
$transaction = $manager->get();
foreach ($data as $value) {
$manager = new Manager();
$manager->setTransaction($transaction);
$manager->project_id = $project_id;
$manager->role = "I";
$manager->username = $start++;
$manager->password = self::getRandString();
$manager->name = $value;
if ($manager->save() == false) {
$transaction->rollback("数据插入失败");
}
}
$transaction->commit();
return true;
} catch (TxFailed $e) {
throw new Exception($e->getMessage());
}
}