Esempio n. 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Siswa::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['nim' => $this->nim]);
     $query->andFilterWhere(['like', 'nama', $this->nama])->andFilterWhere(['like', 'kelas', $this->kelas])->andFilterWhere(['like', 'alamat', $this->alamat]);
     return $dataProvider;
 }
Esempio n. 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Siswa::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id_kelas' => $this->id_kelas, 'tgl_lahir' => $this->tgl_lahir]);
     $query->andFilterWhere(['like', 'nis', $this->nis])->andFilterWhere(['like', 'nama', $this->nama])->andFilterWhere(['like', 'password', $this->password])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'tempat_lahir', $this->tempat_lahir])->andFilterWhere(['like', 'no_telp', $this->no_telp])->andFilterWhere(['like', 'jns_kelamin', $this->jns_kelamin])->andFilterWhere(['like', 'alamat', $this->alamat])->andFilterWhere(['like', 'foto', $this->foto]);
     return $dataProvider;
 }
 public function proses_import(Request $request)
 {
     ini_set('max_execution_time', 300);
     $rules = ['excel' => 'required'];
     $pesan = ['excel.required' => 'File excel harus diisi'];
     $validasi = Validator::make($request->all(), $rules, $pesan);
     if ($validasi->fails()) {
         return Redirect::back()->withErrors($validasi)->withInput();
     }
     $excel = $request->file('excel');
     //ambil sheet pertama
     $excels = Excel::selectSheetsByIndex(0)->load($excel, function ($reader) {
         //options jika ada
     })->get();
     //digunakan untuk menghitung total siswa yang masuk
     $counter = 0;
     $rowRules = ['no_peserta' => 'required', 'nisn' => 'required', 'nama' => 'required', 'jk' => 'required', 'rombel' => 'required'];
     foreach ($excels as $row) {
         //membuat validasi untuk row di excel
         //jangan lupa mengubah $row menjadi array
         $validasi = Validator::make($row->toArray(), $rowRules);
         //skip baris ini jika tidak valid, langsung ke baris berikutnya
         if ($validasi->fails()) {
             continue;
         }
         $cek = Siswa::where('nis', $row['nisn'])->count();
         if ($cek > 0) {
             continue;
         }
         $pass = mt_rand() . '@';
         $data = array('nis' => $row['nisn'], 'nama' => $row['nama'], 'kd_kelas' => $row['rombel'], 'jk' => $row['jk'], 'tmp_lahir' => $row['tempat'], 'tgl_lahir' => $row['tanggal'], 'nik' => $row['nik'], 'agama' => $row['agama'], 'alamat' => $row['alamat'], 'rt' => $row['rt'], 'rw' => $row['rw'], 'dusun' => $row['dusun'], 'kelurahan' => $row['kelurahan'], 'kecamatan' => $row['kecamatan'], 'kode_pos' => $row['kode_pos'], 'no_skhun' => $row['skhun'], 'nm_ayah' => $row['ayah'], 'nm_ibu' => $row['ibu'], 'no_peserta' => $row['no_peserta'], 'password' => Hash::make($pass), 'password_asli' => $pass, 'status' => 0);
         DB::table('siswa')->insert($data);
         $counter++;
     }
     Session::flash('pesan', "Berhasil mengimport " . $counter . " siswa");
     return Redirect::to('admin/siswa');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $kelas = Kelas::find($id);
     //cek siswa dengan kelas ini
     $siswa = Siswa::where('kd_kelas', $id)->count();
     if ($siswa > 0) {
         Session::flash('pesan', "Data tidak dapat dihapus karena ada siswa yang masih menggunakan kelas ini");
         return Redirect::back();
     }
     //cek detail_jadwal
     $detail = DB::table('detail_jadwal')->where('kd_kelas', $id)->count();
     if ($detail > 0) {
         Session::flash('pesan', "Data tidak dapat dihapus karena ada data jadwal yang masih menggunakan kelas ini");
         return Redirect::back();
     }
     $kelas->delete();
     Session::flash('pesan', "Data Berhasil dihapus");
     return Redirect::to('admin/kelas');
 }
Esempio n. 5
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($kelas_id, $id)
 {
     //
     $siswa = Siswa::find($id);
     if ($siswa->delete()) {
         return response()->json(array('success' => TRUE));
     }
 }
Esempio n. 6
0
 function cetak_kartu_peserta(Request $request)
 {
     $type = $request->input('type');
     $kelas = $data['kelas'] = $request->input('kelas');
     if ($kelas == 'semua') {
         $data['siswa'] = Siswa::all();
     } else {
         $data['siswa'] = Siswa::where('kd_kelas', $kelas)->get();
     }
     $pdf = PDF::loadView('admin.laporan.cetak-kartu-peserta', $data)->setPaper('f4');
     return $pdf->stream();
 }
 /**
  * Finds the Siswa model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return Siswa the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Siswa::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Esempio n. 8
0
 public function getSiswa()
 {
     $siswa = Siswa::find($this->getNis());
     return $siswa;
 }
Esempio n. 9
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getSiswas()
 {
     return $this->hasMany(Siswa::className(), ['id_kelas' => 'id_kelas']);
 }
Esempio n. 10
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getNisSiswa()
 {
     return $this->hasOne(Siswa::className(), ['nis' => 'nis']);
 }
Esempio n. 11
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show(AbsensiRequest $request)
 {
     //
     $input = $request->except('_token');
     $data['title'] = 'Lihat Absensi';
     $data['fulltanggal'] = date('d F Y', strtotime($input['tanggal'] . '-' . $input['bulan'] . '-' . $input['tahun']));
     $data['siswa'] = Siswa::with(['absensi' => function ($query) use($input) {
         $query->where('tanggal', '=', $input['tanggal'])->where('bulan', '=', $input['bulan'])->where('tahun', '=', $input['tahun']);
     }])->where('id_kelas', '=', $input['kelas'])->get();
     if ($this->auth->user()->status == 'admin') {
         return View('backend.absensi.show', $data);
     }
     return View('guru.absensi.show', $data);
 }
Esempio n. 12
0
 public function ambilsiswa($id)
 {
     $siswa = Models\Siswa::where('id_kelas', $id)->get();
     return response()->json($siswa);
 }
Esempio n. 13
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $siswa = Siswa::find($id);
     $siswa->delete();
     Session::flash('pesan', "Data berhasil dihapus");
     return Redirect::to('admin/siswa');
 }
 public function show_all_siswa()
 {
     $siswas = Siswa::paginate(10);
     //return $siswas;
     return view('content\\scadmin\\list_siswa')->with('siswas', $siswas);
 }
Esempio n. 15
0
 public function siswa()
 {
     $siswa = Siswa::all();
     return json_encode($siswa);
 }