public function getTambah(Request $request)
 {
     $data['jabatan'] = Jabatan::paginate(10);
     $dt = new Jabatan();
     $dt->nama = $request->nama;
     $dt->save();
     return redirect()->route('jabatan', $data);
 }
 public function getTambah(Request $request)
 {
     $data['jabatan'] = Jabatan::paginate(10);
     /* Validasi */
     $this->validate($request, ['nama' => 'required|unique:app_jabatan']);
     /* end validasi */
     $dt = new Jabatan();
     $dt->nama = $request->nama;
     $dt->save();
     return redirect()->route('jabatan', $data)->with(session()->flash('success', 'Data Berhasil Tersimpan !!'));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     // Validation //
     $validation = Validator::make($request->all(), ['name' => 'required|unique:jabatans|max:255']);
     // Check if it fails //
     if ($validation->fails()) {
         return redirect()->back()->withInput()->with('errors', $validation->errors());
     }
     $author = Auth::user()->id;
     $jabatan = new Jabatan();
     $jabatan->name = $request->input('name');
     $jabatan->status = 1;
     $jabatan->save();
     Alert::success('Berhasil membuat, ' . $request->input('name') . ' !')->persistent("Close");
     return redirect('jabatan/list')->with('message', 'Berhasil menambah jabatan !');
 }
 public function uploadFile()
 {
     try {
         Excel::load(Input::file('file'), function ($reader) {
             foreach ($reader->toObject() as $row) {
                 if (KartuIndukPegawai::where('nip', $row->nip)->exists()) {
                     //do nothing;
                 } else {
                     $kartu_induk_pegawais = new KartuIndukPegawai();
                     $kartu_induk_pegawais->nip = $row->nip;
                     $kartu_induk_pegawais->karpeg = $row->karpeg;
                     $kartu_induk_pegawais->karis_karsu = $row->karis_karsu;
                     $kartu_induk_pegawais->nama_lengkap = $row->nama_lengkap;
                     $kartu_induk_pegawais->tempat_lahir = $row->tempat_lahir;
                     $kartu_induk_pegawais->tgl_lahir = date("Y-m-d", strtotime($row->tgl_lahir));
                     $kartu_induk_pegawais->jenis_kelamin = $row->jenis_kelamin;
                     $kartu_induk_pegawais->status_perkawinan = $row->status_perkawinan;
                     $kartu_induk_pegawais->tgl_masuk_pegawai = date("Y-m-d", strtotime($row->tgl_masuk_pegawai));
                     $kartu_induk_pegawais->status_kepegawaian = $row->status_kepegawaian;
                     $kartu_induk_pegawais->agama = $row->agama;
                     $kartu_induk_pegawais->jenis_kepegawaian = $row->jenis_kepegawaian;
                     $kartu_induk_pegawais->tgl_pensiun = date("Y-m-d", strtotime($row->tgl_pensiun));
                     $kartu_induk_pegawais->foto = 'no-foto.png';
                     $kartu_induk_pegawais->save();
                     //process jabatan
                     $jabatans = new Jabatan();
                     $jabatans->kartu_induk_pegawai_id = $kartu_induk_pegawais->id;
                     $jabatans->tmt_pangkat = NULL;
                     $jabatans->save();
                 }
             }
         });
         Session::flash('message', 'Import File telah sukses.');
         return Redirect::to('import-file');
     } catch (\Exception $e) {
         Session::flash('message', 'Import File Error');
         //$e->getMessage()
         Session::flash('alert-class', 'alert-danger');
         return Redirect::to('import-file');
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(KartuIndukPegawaiRequest $request)
 {
     $kartu_induk_pegawais = new KartuIndukPegawai();
     $kartu_induk_pegawais->nip = Input::get('nip');
     $kartu_induk_pegawais->karpeg = Input::get('karpeg');
     $kartu_induk_pegawais->karis_karsu = Input::get('karis_karsu');
     $kartu_induk_pegawais->nama_lengkap = Input::get('nama_lengkap');
     $kartu_induk_pegawais->tempat_lahir = Input::get('tempat_lahir');
     $kartu_induk_pegawais->tgl_lahir = date("Y-m-d", strtotime(Input::get('tgl_lahir')));
     $kartu_induk_pegawais->jenis_kelamin = Input::get('jenis_kelamin');
     $kartu_induk_pegawais->status_perkawinan = Input::get('status_perkawinan');
     $kartu_induk_pegawais->tgl_masuk_pegawai = date("Y-m-d", strtotime(Input::get('tgl_masuk_pegawai')));
     $kartu_induk_pegawais->status_kepegawaian = Input::get('status_kepegawaian');
     $kartu_induk_pegawais->agama = Input::get('agama');
     $kartu_induk_pegawais->jenis_kepegawaian = Input::get('jenis_kepegawaian');
     $kartu_induk_pegawais->tgl_pensiun = date("Y-m-d", strtotime(Input::get('tgl_pensiun')));
     $kartu_induk_pegawais->save();
     // process image
     $image = $request->file('foto');
     if (!empty($image)) {
         $fotoName = 'peg' . $kartu_induk_pegawais->id . '.' . $request->file('foto')->getClientOriginalExtension();
         $request->file('foto')->move(base_path() . '/public/images/pegawai/', $fotoName);
         $img = Image::make(base_path() . '/public/images/pegawai/' . $fotoName);
         $img->resize(100, null, function ($constraint) {
             $constraint->aspectRatio();
         });
         $img->save();
         $kartu_induk_pegawai_fotos = KartuIndukPegawai::find($kartu_induk_pegawais->id);
         $kartu_induk_pegawai_fotos->foto = $fotoName;
         $kartu_induk_pegawai_fotos->save();
     }
     //process jabatan
     $jabatans = new Jabatan();
     $jabatans->kartu_induk_pegawai_id = $kartu_induk_pegawais->id;
     $jabatans->save();
     Session::flash('message', 'Input Kartu Induk Pegawai NIP: ' . $kartu_induk_pegawais->nip . ' Sukses');
     return Redirect::to('kartu-induk-pegawai/create');
 }
 public function store(Request $request)
 {
     // Start Check Authorization
     $invalid_auth = 1;
     $authRole = Auth::user()->UserRoles->role;
     if ($authRole == 1 or $authRole == 3) {
         $invalid_auth = 0;
     }
     if ($invalid_auth == 1) {
         Alert::error('Anda tidak memilik akses ini')->persistent('close');
         return redirect('dashboard');
     }
     // End Check Authorization
     // Validation //
     $validation = Validator::make($request->all(), ['name' => 'required|unique:jabatans|max:255']);
     // Check if it fails //
     if ($validation->fails()) {
         return redirect()->back()->withInput()->with('errors', $validation->errors());
     }
     $author = Auth::user()->id;
     $jabatan = new Jabatan();
     $jabatan->name = $request->input('name');
     $jabatan->status = 1;
     $jabatan->save();
     Alert::success('Berhasil membuat, ' . $request->input('name') . ' !')->persistent("Close");
     return redirect('jabatan/list')->with('message', 'Berhasil menambah jabatan !');
 }