Пример #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Dosen::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' => $this->id]);
     $query->andFilterWhere(['like', 'nama', $this->nama]);
     return $dataProvider;
 }
 public function registerdsn()
 {
     $rules = array('nik' => 'required', 'first_name' => 'required', 'last_name' => 'required', 'email' => 'required|email', 'password' => 'required|min:5');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::to('/register')->with('msge', 'Ada kesalahan, silahkan mencoba kembali dan perhatikan ketentuan yang berlaku');
     } else {
         #cek nik apakah terdaftar or tidak
         $input = Input::all();
         $dos = new Dosen();
         $cekdos = Dosen::find($dos->nik = $input['nik']);
         #mengecek nik apakah sudah digunakan atau belum
         $in = Input::get('nik');
         $user = DB::table('users')->where('nik', '=', $in)->count();
         if (!$cekdos) {
             return Redirect::to('/register')->with('msge', 'NIK anda tidak terdaftar!');
         } elseif ($user >= 1) {
             return Redirect::to('/register')->with('msge', 'NIK anda sudah digunakan untuk daftarkan akun');
         } else {
             try {
                 #mencari group mahasiswa
                 $dosenGroup = Sentry::findGroupByName('dosen');
                 $dosen = Sentry::register(array('nik' => Input::get('nik'), 'first_name' => Input::get('first_name'), 'last_name' => Input::get('last_name'), 'email' => Input::get('email'), 'password' => Input::get('password')), false);
                 #$activationCode = $dosen->getActivationCode();
                 #memasukkan data dalam group
                 $dosen->addGroup($dosenGroup);
                 $emailVariables = ['first_name' => $dosen->first_name, 'email' => $dosen->email, 'code' => $dosen->getActivationCode()];
             } catch (Cartalyst\Sentry\Users\UserExistsException $e) {
                 return Redirect::to('/register')->with('msge', 'Email anda sudah pernah digunakan, silahkan coba email yang lain.');
             }
             Mail::send('mailTemplate.activationdsn', $emailVariables, function ($pesan) use($dosen) {
                 $pesan->to($dosen->email, $dosen->first_name . ' ' . $dosen->last_name)->subject('Aktifasi akun AKOSTMIK anda :)');
             });
             return Redirect::to('/logindosen')->with('msgs', 'Selamat, anda berhasil mendaftar. Agar bisa login silahkan buka link aktivasi yang kami kirim ke email ' . $dosen->email);
         }
     }
 }
Пример #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getDosen()
 {
     return $this->hasOne(Dosen::className(), ['id' => 'dosen_id']);
 }
 public function destroy($id)
 {
     $dosen = Dosen::where('nik', '=', $id)->first();
     $dosen->delete();
     return redirect()->route('dosen.index');
 }
Пример #5
0
 /**
  * Finds the Dosen model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Dosen the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Dosen::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Пример #6
0
 public function detail($nik)
 {
     $dosen = Dosen::find($nik);
     return View::make('dosen.detail')->with('dosen', $dosen);
 }
Пример #7
0
 public function delete($id)
 {
     $item = Dosen::findOrFail($id);
     $item->delete();
 }