Esempio n. 1
0
 /**
  * Creates a new Expertise and returns the Expertise Object.
  * @return [type] [description]
  */
 public function createExpertise($title, $notes = null, $id = null, $requested = null)
 {
     $advisor = Advisor::find($id);
     $expertise = new Expertise();
     $expertise->title = $title;
     $expertise->notes = $notes;
     $expertise->save();
     if ($id == null) {
         return $expertise;
     }
     if ($requested == true) {
         $expertise->requested_adv_id = $id;
         $expertise->requested = true;
         $expertise->save();
     }
     return $expertise;
 }
 public function storeExpertise()
 {
     $expertise = new Expertise();
     $expertise->title = Input::get('title');
     $expertise->notes = Input::get('notes');
     $expertise->save();
     return Redirect::intended('advisor.dashboard');
 }
Esempio n. 3
0
 public function actionZhuanye()
 {
     $todo = array();
     $i = 0;
     $filename = './public/zhuanye.txt';
     $result = file($filename);
     $result = array_map('check', $result);
     $keys = array();
     $keys[0] = null;
     $values = array();
     $values[0] = null;
     foreach ($result as $item) {
         $zhuanye = explode('=', $item);
         $keys[] = $zhuanye[0];
         $values[] = $zhuanye[1];
     }
     //		echo array_search('0101', $keys);
     for ($t = 1; $t <= count($keys); $t++) {
         //			$zhuanyedaima = strlen($zhuanye[0]);
         //			$zhuanyedaima = chunk_split($zhuanye[0],2);
         preg_match_all('/(\\d{2})(\\d{2})?(\\d{2})?/i', $keys[$t], $zhuanyedaima);
         $todo[$t] = array('id' => $t, 'daima' => $zhuanyedaima[0][0], 'name' => $values[$t]);
         if (intval($zhuanyedaima[1][0]) && !intval($zhuanyedaima[2][0])) {
             $todo[$t]['pid'] = 0;
             //array_search($zhuanyedaima[1][0], $keys);
         }
         if (intval($zhuanyedaima[2][0]) && !intval($zhuanyedaima[3][0])) {
             $todo[$t]['pid'] = array_search(strval($zhuanyedaima[1][0]), $keys);
             //				echo '2'.$zhuanyedaima[1][0]."\n\r";
         }
         if (intval($zhuanyedaima[2][0]) && intval($zhuanyedaima[3][0])) {
             $todo[$t]['pid'] = array_search($zhuanyedaima[1][0] . $zhuanyedaima[2][0], $keys);
         }
     }
     $todo[1]['pid'] = 0;
     $todo[2]['pid'] = 1;
     array_pop($todo);
     //		UtilHelper::dump($todo);
     foreach ($todo as $item) {
         //			echo "id:".$item['id']."\t pid:".$item['pid']."\t name:".$item['name']."\tdaima:".$item['daima']."<br />";
         $expertise = new Expertise();
         $expertise->id = $item['id'];
         $expertise->pid = $item['pid'];
         $expertise->name = $item['name'];
         if ($expertise->save()) {
             echo 'ok' . $expertise->id;
         } else {
             echo CHtml::errorSummary($expertise);
         }
     }
 }