public function store(Request $request)
 {
     $post = $request->all();
     if ($request != " ") {
         $i = $post['info'];
         if ($i != " ") {
             Info::where('id', 1)->update(array('info' => $i));
         }
         return redirect('grupas_info');
     }
 }
Exemplo n.º 2
0
 /**
  * Show the specified photo comment.
  *
  * @param  int  $photoId
  * @param  int  $commentId
  * @return Response
  */
 public static function updateInfo($city)
 {
     $url = 'http://api.openweathermap.org/data/2.5/weather?q=' . $city . '&appid=2de143494c0b295cca9337e1e96b00e0';
     $json = "";
     try {
         $json = file_get_contents($url);
     } catch (Exception $e) {
         echo $e->getMessage();
     }
     $obj = json_decode($json);
     $weather_object = new \stdClass();
     foreach ($obj->weather as $key => $value) {
         $weather_object->main = $value->main;
         $weather_object->description = $value->description;
     }
     $weather_object->temperature = $obj->main->temp;
     $weather_object->pressure = $obj->main->pressure;
     $weather_object->humidity = $obj->main->humidity;
     $weather_object->temp_min = $obj->main->temp_min;
     $weather_object->temp_max = $obj->main->temp_max;
     if (!empty($obj->main->sea_level)) {
         $weather_object->sea_level = $obj->main->sea_level;
     } else {
         $weather_object->sea_level = "";
     }
     if (!empty($obj->main->grnd_level)) {
         $weather_object->grnd_level = $obj->main->grnd_level;
     } else {
         $weather_object->grnd_level = "";
     }
     $weather_object->speed = $obj->wind->speed;
     if (!empty($obj->wind->degree)) {
         $weather_object->degree = $obj->wind->deg;
     } else {
         $weather_object->degree = "";
     }
     $weather_object->sunrise = $obj->sys->sunrise;
     $weather_object->sunset = $obj->sys->sunset;
     $time = time();
     $date = date("Y-m-d");
     $info = Info::where('city', $city)->where('date', $date)->get();
     if ($info->isEmpty()) {
         Info::make($weather_object->main, $weather_object->description, $weather_object->temperature, $weather_object->pressure, $weather_object->humidity, $weather_object->temp_min, $weather_object->temp_max, $weather_object->speed, $weather_object->sunrise, $weather_object->sunset, $time, $date, $city, $weather_object->degree, $weather_object->sea_level, $weather_object->grnd_level);
     } else {
         $prev_info = Info::where('city', $city)->where('date', $date)->orderBy('created_at', 'desc')->first();
         if ($prev_info->city != $city || $prev_info->main != $weather_object->main || $prev_info->description != $weather_object->description || abs($prev_info->temperature - $weather_object->temperature) != 0 || abs($prev_info->pressure - $weather_object->pressure) != 0 || abs($prev_info->humidity - $weather_object->humidity) != 0 || abs($prev_info->temp_min - $weather_object->temp_min) != 0 || abs($prev_info->sea_level - $weather_object->sea_level) != 0 || abs($prev_info->grnd_level - $weather_object->grnd_level) != 0 || date("Y-m-d h:i:s", $weather_object->sunrise) != $prev_info->sunrise || date("Y-m-d h:i:s", $weather_object->sunset) != $prev_info->sunset) {
             Info::make($weather_object->main, $weather_object->description, $weather_object->temperature, $weather_object->pressure, $weather_object->humidity, $weather_object->temp_min, $weather_object->temp_max, $weather_object->speed, $weather_object->sunrise, $weather_object->sunset, $time, $date, $city, $weather_object->degree, $weather_object->sea_level, $weather_object->grnd_level);
             echo View::make('weather', array('weather_object' => $weather_object, 'prev_info' => $prev_info));
             exit;
         }
     }
     echo View::make('weather', array('weather_object' => $weather_object));
 }
 public function healthInfos($id)
 {
     $trainee = Info::where('course_id', '=', $id)->get();
     return view('view_trainee_report.healthInfos', compact('trainee'));
     //        $trainee = TraineeCourse::where('course_id','=',$id)->get();
     //        dd($trainee);
     //        return view('view_trainee_report.healthInfos', compact('trainee'));
     $trainee = DB::table('users')->join('traineecourses', 'traineecourses.trainee_id', '=', 'users.id')->join('courses', 'courses.id', '=', 'traineecourses.course_id')->where('courses.id', $id)->get();
     //dd($trainee);
     $id = [];
     $name = [];
     $abc = array();
     foreach ($trainee as $tra) {
         if (HealthReport::where('user_id', '=', $tra->trainee_id)->exists() and HealthExam::where('user_id', '=', $tra->trainee_id)->exists()) {
             $abc[$tra->name] = array('id' => $tra->trainee_id, 'name' => $tra->name);
             //dd($abc[$tra->name]);
         }
     }
     //return print_r($abc);
     return view('view_trainee_report.healthInfos')->with('abc', $abc);
 }
 public function update_info($id, InfoFormRequest $request)
 {
     $input = $request->all();
     $expertisearray = $input['expertise'];
     $expertiseString = $request->get('expertise');
     $expertise = serialize($expertiseString);
     $diseasearray = $input['diseases'];
     //return dd($diseasearray);
     $diseasesString = $request->get('diseases');
     $diseases = serialize($diseasesString);
     //return dd($diseases);
     //dd($diseases);
     if (isset($input['image'])) {
         $Image = $input['image'];
         //dd($Image);
         $imagePath = $this->imageUpload($Image);
         //call public function imageUpload for small img
     } else {
         $imagePath = Info::where('id', '=', $id)->pluck('filepath');
         //dd($imagePath);
     }
     $info = Info::whereId($id)->firstOrFail();
     $info->name = $request->get('name');
     $info->gender = $request->get('gender');
     $info->trainee_id = $request->get('trainee_id');
     $info->trainee_login_id = $request->get('trainee_login_id');
     $info->institution = $request->get('institution');
     $info->educational_qualification = $request->get('educational_qualification');
     $info->service_experience = $request->get('service_experience');
     $info->experience_year = $request->get('experience_year');
     $info->date_of_birth = $request->get('date_of_birth');
     $info->birth_place = $request->get('birth_place');
     $info->join_date = $request->get('join_date');
     $info->guardians_name = $request->get('guardians_name');
     $info->village = $request->get('village');
     $info->post_office = $request->get('post_office');
     $info->sub_district = $request->get('sub_district');
     $info->district = $request->get('district');
     $info->service_station = $request->get('service_station');
     $info->marital = $request->get('marital');
     $info->ph_home = $request->get('ph_home');
     $info->ph_office = $request->get('ph_office');
     $info->ph_mobile = $request->get('ph_mobile');
     $info->diseases = $diseases;
     $info->soprts = $request->get('soprts');
     $info->hobby = $request->get('hobby');
     $info->expertise = $expertise;
     $info->interested_game = $request->get('interested_game');
     $info->height = $request->get('height');
     $info->weight = $request->get('weight');
     $info->waist_abdomen = $request->get('waist_abdomen');
     $info->chest = $request->get('chest');
     $info->weight_end_course = $request->get('weight_end_course');
     $info->filepath = $imagePath;
     if ($request->get('status') != null) {
         $info->status = 0;
     } else {
         $info->status = 1;
     }
     $info->save();
     return redirect(action('TrainersController@edit_profile', $info->id))->with('status', 'The trainees information has been updated!');
 }
Exemplo n.º 5
0
 public static function sign($id, $proId, $username)
 {
     $goods = self::where(['id' => $proId, 'receiver' => $username])->first();
     if ($goods->update(['is_send' => 1])) {
         $user = Info::where('user_id', $id)->first();
         $user->score = $user->score + 10;
         $user->inc_score = $user->inc_score + 10;
         $user->save();
         $user = Info::where('user_id', $id)->first();
         $level = floor($user->score / 30) + 1;
         $user->levell = $level;
         $user->save();
         return self::success();
     }
     return self::fail();
 }
 public function guest(Request $request)
 {
     $result = $this->check($request);
     $id = $request->input('id');
     $user = Info::where('user_id', $id)->first();
     $user->username = User::find($id)->username;
     $user->src = 'uploads/' . $user->head_photo;
     $data = Goods::personal($id, 8, 'sending');
     $news = Comments::newsCount($result['loginFlag'], $result['username']);
     return view('pc.guest', ['key' => '', 'loginFlag' => $result['loginFlag'], 'username' => $result['username'], 'sentNum' => $news['sentNum'], 'mesNum' => $news['mesNum'], 'max' => $data['maxPage'], 'user' => $user, 'data' => $data['data']]);
 }
 public function headPhoto(Request $request)
 {
     $file = $request->input('file');
     $userId = $request->session()->get('id');
     $base64 = base64_decode($file);
     $path = 'uploads';
     $filename = time() . '.png';
     $destination = $path . "/" . $filename;
     if (file_put_contents($filename, $base64)) {
         if (rename($filename, $destination)) {
             Info::where('user_id', $userId)->update(['head_photo' => $filename]);
             return $this->success('上传成功', ['src' => 'uploads/' . $filename]);
         }
         return $this->fail('上传失败');
     }
     return $this->fail('上传失败');
 }
Exemplo n.º 8
0
 public function index(Info $i, $column = 'id', $type = null)
 {
     $column = $i->getColumn($column);
     $type = $i->getType($type);
     $q = $this->request->input('q');
     $adv = $this->request->input('adv');
     if ($q) {
         $infos = Info::where('claimant', 'like', '%' . $q . '%')->orderBy($column, $type)->get();
     } else {
         if ($adv) {
             $infos = $i->getAdvancedSearchModel($this->request);
         } else {
             $infos = Info::orderBy($column, $type)->get();
         }
     }
     $total = count($infos);
     $chart_inc = array_fill_keys(array('dm', 'policy', 'documents'), 0);
     foreach ($infos as $info) {
         if ($info->dm == '') {
             $chart_inc['dm'] += 1;
         }
         if ($info->policy == '') {
             $chart_inc['policy'] += 1;
         }
         if ($info->documents == 'incomplete') {
             $chart_inc['documents'] += 1;
         }
     }
     $chart_complete = array_fill_keys(array('documents'), 0);
     foreach ($infos as $info) {
         if ($info->documents == 'complete') {
             $chart_complete['documents'] += 1;
         }
     }
     $chart_complete['dm'] = $total - $chart_inc['dm'];
     $chart_complete['policy'] = $total - $chart_inc['policy'];
     $stages = array_fill_keys(array('stage_1', 'stage_2', 'stage_3', 'stage_4'), 0);
     foreach ($infos as $info) {
         if ($info->stage == 1) {
             $stages['stage_1'] += 1;
         }
         if ($info->stage == 2) {
             $stages['stage_2'] += 1;
         }
         if ($info->stage == 3) {
             $stages['stage_3'] += 1;
         }
         if ($info->stage == 4) {
             $stages['stage_4'] += 1;
         }
     }
     $stats = array_fill_keys(array('denied', 'approved', 'closed', 'pending'), 0);
     foreach ($infos as $info) {
         if ($info->claim_status == 'denied') {
             $stats['denied'] += 1;
         }
         if ($info->claim_status == 'approved') {
             $stats['approved'] += 1;
         }
         if ($info->claim_status == 'closed') {
             $stats['closed'] += 1;
         }
         if ($info->claim_status == 'pending') {
             $stats['pending'] += 1;
         }
     }
     $months = array_fill_keys(array('jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'), 0);
     foreach ($infos as $m) {
         if ($m->encoded->month == '1') {
             $months['jan'] += 1;
         }
         if ($m->encoded->month == '2') {
             $months['feb'] += 1;
         }
         if ($m->encoded->month == '3') {
             $months['mar'] += 1;
         }
         if ($m->encoded->month == '4') {
             $months['apr'] += 1;
         }
         if ($m->encoded->month == '5') {
             $months['may'] += 1;
         }
         if ($m->encoded->month == '6') {
             $months['jun'] += 1;
         }
         if ($m->encoded->month == '7') {
             $months['jul'] += 1;
         }
         if ($m->encoded->month == '8') {
             $months['aug'] += 1;
         }
         if ($m->encoded->month == '9') {
             $months['sep'] += 1;
         }
         if ($m->encoded->month == '10') {
             $months['oct'] += 1;
         }
         if ($m->encoded->month == '11') {
             $months['nov'] += 1;
         }
         if ($m->encoded->month == '12') {
             $months['dec'] += 1;
         }
     }
     $claims_amount = $i->claimsAmount($infos);
     $deadline_names = [];
     foreach ($infos as $info) {
         $deadline = $i->isDeadLineToday($info->dead_line);
         $info['deadline_today'] = $deadline;
         if ($deadline == 'deadline' && $info->claim_status == 'pending') {
             $deadline_names[$info->name] = $info;
         }
     }
     return view('home')->with('chart_inc', $chart_inc)->with('chart_complete', $chart_complete)->with('stages', $stages)->with('stats', $stats)->with('months', $months)->with('info', $infos)->with('claims_amount', $claims_amount)->with('message', session('message'))->with('type', $type)->with('column', $column)->with('symbol', $i->getSymbol($type))->with('picture', \App\User::profilePicture())->with('deadline_names', $deadline_names)->with('q', $q)->with('adv', $adv);
 }
 public function healthInfos($id)
 {
     $trainee = Info::where('course_id', '=', $id)->get();
     return view('view_trainee_report.healthInfos', compact('trainee'));
 }