Пример #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
 public function detail($nik)
 {
     $dosen = Dosen::find($nik);
     return View::make('dosen.detail')->with('dosen', $dosen);
 }