Exemple #1
0
 public function destroy(Admin $admin)
 {
     if ($admin->delete()) {
         return $this->success('删除成功');
     }
     return $this->error('删除失败');
 }
 public function loginAction()
 {
     //khi tao admin trong database
     //dung lenh : update tablenam set columpass = md5(columpass);
     if ($this->getPostData()) {
         $post = $this->getPostData();
         $t = Admin::getByName($post['email']);
         if (count($t) > 0) {
             if ($t[0]['password'] == md5($post['password'])) {
                 $this->app['session']->set('admin_authed', $post['email']);
                 return $this->redirect('admin_home');
             }
         }
         $data['error'] = "Tên hoặc mật khẩu không đúng @";
         return $this->render('admin/login.html.twig', $data);
     }
     return $this->render('admin/login.html.twig');
 }
 function getByName($email)
 {
     return Admin::where('name', $email)->get();
 }