public function addbrand()
 {
     $brand = Input::get('brandname');
     $brandlogo = Input::file('brandlogo');
     $valid = ['brandname' => $brand, 'brandlogo' => $brandlogo];
     Xvalidate::filter('createbrand');
     $validation = Xvalidate::these($valid);
     if ($validation->passes()) {
         $data['name'] = strtolower(trim(extract_char($brand, ['text', 'int'])));
         if ($brandlogo !== NULL) {
             $data['brandlogo'] = $this->_prepareImage($brandlogo);
         }
         //Log area
         $log['products'] = '[BRAND] ' . $data['name'];
         $log['stocktype'] = 'create';
         $this->_saveActivityLog($log);
         //Saving the brand into database
         $brandObj = Brand::Create($data);
         $result['status'] = 'success';
         $result['message'] = 'Created successfully!';
         $result['url'] = URL::route('adminstock');
         return Response::json($result);
     } else {
         return Response::json($validation->messages());
     }
 }
Exemple #2
0
 public function isValid()
 {
     Xvalidate::filter('saveCustomer');
     $validation = Xvalidate::these($this->toArray());
     if (!$validation->passes()) {
         $this->validatorStatus = $validation->messages();
         return false;
     }
     return true;
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function auth()
 {
     $username = strtolower(Input::get('username'));
     $password = Input::get('password');
     $user = array('username' => $username, 'password' => $password);
     //This would redirect you to forget password if true
     if ($this->_isForgetPassword($username)) {
         $fpwd_stat = $this->_gotoForgetPassword($username, $password);
         return Response::json($fpwd_stat);
     }
     Xvalidate::filter('login');
     $validation = Xvalidate::these($user);
     if ($validation->passes() === FALSE) {
         //tt($validation->messages());
         return Response::json($validation->messages());
     }
     if ($this->firstUser() === TRUE) {
         $ds = md5(strtotime('now'));
         Session::put('firstuserurl', $ds);
         $data['url'] = URL::route('createAdmin.firstUserForm') . '?firstuserurl=' . Session::get('firstuserurl');
         $data['message'] = '<b>NOTE:</b> First time login attempt, would redirect you to create the software ADMINISTRATOR';
         $data['status'] = 'info';
         //tt($data['url']);
         return Response::json($data);
     }
     if ($this->AuthLogin($user) === FALSE) {
         $data['status'] = 'danger';
         $data['message'] = 'User does not exists..';
         return Response::json($data);
     }
     if (Auth::user()->isenabled != 1) {
         $this->logout();
         $data['status'] = 'danger';
         $data['message'] = 'Account is disabled. Contact administrator';
         return Response::json($data);
     }
     //Log the login activity
     $this->saveLoginActivity();
     //Update Logged in time
     $this->updateLoggedInfo();
     $this->updateisLoggedin(1);
     $data['status'] = 'success';
     $data['message'] = 'Login successful. Redirecting...';
     $data['url'] = URL::route($this->_loginRoleURL());
     return Response::json($data);
 }