public function run()
 {
     $faker = Faker\Factory::create();
     for ($id = 1; $id < 19; $id++) {
         CommonId::create(['user_id' => $id, 'tin' => $faker->randomElement(['646933026598', '532069354265', '123465987567']), 'philhealth' => $faker->randomElement(['646945126330', '566265320695', '123596234567']), 'pagibig' => $faker->randomElement(['646365989330', '532365980695', '123365984567']), 'sss' => $faker->randomElement(['646933659830', '532063215695', '123365984567'])]);
     }
 }
 public function postEditCommonid($id)
 {
     $user = User::find($id);
     $comids = CommonId::where('user_id', $id)->first();
     $validator = Validator::make(Input::all(), CommonId::$rules);
     if ($validator->fails()) {
         return Redirect::route('emp.edit-commonid', $comids->user_id)->withErrors($validator)->withInput();
     }
     $comids->update(['tin' => Input::get('tin'), 'philhealth' => Input::get('philhealth'), 'pagibig' => Input::get('pagibig'), 'sss' => Input::get('sss'), 'gsisbp' => Input::get('gsisbp'), 'gsispolicy' => Input::get('gsispolicy'), 'gsisoptional' => Input::get('gsisoptional'), 'educplan' => Input::get('educplan')]);
     $audit = AuditTrail::create(['user_id' => Auth::id(), 'role' => 'Employee Management Admin', 'action' => 'edited ' . $user->firstname . ' ' . $user->lastname . '\'s Common ID information.']);
     return Redirect::route('profile', $id)->with('alert', 'success|Common Ids have been updated.');
 }
 public function getUserPdf($id)
 {
     $user = User::find($id);
     $comids = CommonId::where('user_id', $user->id)->first();
     $cont = ContactInfo::where('user_id', $user->id)->first();
     $parents = Parents::where('user_id', $user->id)->get();
     $schools = School::where('user_id', $user->id)->first();
     if ($user->gender == 'Male') {
         $gender = 'his';
     } else {
         $gender = 'her';
     }
     $audit = AuditTrail::create(['user_id' => Auth::id(), 'role' => 'User', 'action' => 'printed ' . $gender . ' User Information']);
     if (!$user) {
         App::abort(404);
     }
     Fpdf::AddPage();
     Fpdf::PageNo();
     Fpdf::AliasNbPages('{nb}');
     Fpdf::Image('img/dap.jpg', 10, 5, 150);
     Fpdf::SetFont('Arial', 'B', 10);
     Fpdf::Ln(25);
     Fpdf::Cell(300, 10, 'Date Generated: ' . date("F j, Y"), 0, 2, 'C', 0);
     Fpdf::SetFont('Arial', 'B', 18);
     Fpdf::Ln(10);
     Fpdf::Cell(190, 10, $user->formatName(':fn :ln'), 0, 2, 'C', 0);
     Fpdf::SetFont('Arial', 'B', 9.5);
     Fpdf::SetTextColor(0, 0, 0);
     Fpdf::Cell(80, 10, 'Personal Information', 0, 0, 'C', 0);
     Fpdf::Cell(80, 10, 'Common ID', 0, 1, 'C', 0);
     Fpdf::SetTextColor(0, 0, 0);
     Fpdf::SetFont('Arial', '', 8.5);
     Fpdf::Cell(80, 10, 'Email:   ' . $user->email, 0, 0, 'L', 0);
     Fpdf::Cell(80, 10, 'TIN ID:   ' . $comids->tin, 0, 1, 'L', 0);
     Fpdf::Cell(80, 10, 'Username:   '******'L', 0);
     Fpdf::Cell(80, 10, 'Philhealth:   ' . $comids->philhealth, 0, 1, 'L', 0);
     Fpdf::Cell(80, 10, 'Birthday:   ' . $user->birthday, 0, 0, 'L', 0);
     Fpdf::Cell(80, 10, 'Pag IBIG:   ' . $comids->pagibig, 0, 1, 'L', 0);
     Fpdf::Cell(80, 10, 'Gender:   ' . $user->gender, 0, 0, 'L', 0);
     Fpdf::Cell(80, 10, 'SSS:   ' . $comids->sss, 0, 1, 'L', 0);
     Fpdf::Cell(80, 10, 'Department:   ' . $user->department->name, 0, 0, 'L', 0);
     //Fpdf::Cell(80,10,'Common ID',0,2,'C',0);
     Fpdf::Ln(15);
     Fpdf::SetFont('Arial', 'B', 9.5);
     Fpdf::SetFillColor(90, 90, 90);
     Fpdf::SetTextColor(0, 0, 0);
     Fpdf::Cell(150, 10, 'Parents', 0, 1, 'C', 0);
     foreach ($parents as $parent) {
         if ($parent->parent_id == 1) {
             Fpdf::SetFont('Arial', '', 8.5);
             Fpdf::Cell(10, 10, 'Father', 0, 0, 'C', 0);
         } else {
             Fpdf::SetFont('Arial', '', 8.5);
             Fpdf::Cell(10, 10, 'Mother', 0, 0, 'C', 0);
         }
         Fpdf::Cell(65, 10, 'Name:   ' . $parent->firstname . " " . $parent->lastname, 0, 0, 'L', 0);
         Fpdf::Cell(65, 10, 'Address:   ' . $parent->address, 0, 1, 'L', 0);
     }
     Fpdf::Ln(15);
     Fpdf::SetFont('Arial', 'B', 9.5);
     Fpdf::Cell(150, 10, 'Contact Info', 0, 1, 'C', 0);
     Fpdf::SetFont('Arial', '', 8.5);
     Fpdf::Cell(80, 10, 'Home Number:   ' . $cont->homenum, 0, 0, 'L', 0);
     Fpdf::Cell(80, 10, 'Office Number:   ' . $cont->officenum, 0, 1, 'L', 0);
     Fpdf::Cell(80, 10, 'Mobile Number:   ' . $cont->mobilenum, 0, 0, 'L', 0);
     Fpdf::Cell(80, 10, 'Street:   ' . $cont->street, 0, 1, 'L', 0);
     Fpdf::Cell(80, 10, 'City:   ' . $cont->city, 0, 0, 'L', 0);
     Fpdf::Ln(5);
     Fpdf::Ln(5);
     Fpdf::SetFont('Arial', 'B', 9.5);
     Fpdf::SetFillColor(90, 90, 90);
     Fpdf::SetTextColor(0, 0, 0);
     Fpdf::Cell(180, 10, 'School', 0, 1, 'C', 0);
     Fpdf::SetTextColor(0, 0, 0);
     Fpdf::SetFont('Arial', '', 8.5);
     Fpdf::Cell(65, 10, 'Primary', 0, 0, 'C', 0);
     Fpdf::Cell(65, 10, 'Secondary', 0, 0, 'C', 0);
     Fpdf::Cell(65, 10, 'Tertiary', 0, 1, 'C', 0);
     Fpdf::Cell(65, 10, 'School:   ' . $schools->primary_name, 0, 0, 'L', 0);
     Fpdf::Cell(70, 10, 'School:   ' . $schools->secondary_name, 0, 0, 'L', 0);
     Fpdf::Cell(70, 10, 'School:   ' . $schools->tertiary_name, 0, 1, 'L', 0);
     Fpdf::Cell(65, 10, 'Address:  ' . $schools->primary_address, 0, 0, 'L', 0);
     Fpdf::Cell(70, 10, 'Address:   ' . $schools->secondary_address, 0, 0, 'L', 0);
     Fpdf::Cell(70, 10, 'Address: ' . $schools->tertiary_address, 0, 1, 'L', 0);
     Fpdf::Cell(65, 10, 'Years:   ' . $schools->primary_years, 0, 0, 'L', 0);
     Fpdf::Cell(70, 10, 'Years:   ' . $schools->secondary_years, 0, 0, 'L', 0);
     Fpdf::Cell(70, 10, 'Years:   ' . $schools->tertiary_years, 0, 1, 'L', 0);
     Fpdf::SetY(-30.5);
     Fpdf::SetFont('Arial', 'I', 6);
     Fpdf::SetTextColor(0, 0, 0);
     Fpdf::Cell(0, 10, 'Page ' . Fpdf::PageNo() . "/{nb}", 0, 0, 'C');
     Fpdf::Output();
     exit;
 }