public function isValidSoftwareUser()
 {
     $username = Input::get('username');
     $password = Input::get('password');
     $user = SoftwareUser::where('username', '=', $username)->where('password', '=', $password)->first();
     if (is_null($user)) {
         return json_encode(array('message' => 'wrong'));
     } else {
         Session::put('admin_id', $user->id);
         Session::put('user_type', $user->user_type);
         Session::put('name', $user->name);
         return json_encode(array('message' => 'correct'));
     }
 }
 public function softwareUserComplaints($id)
 {
     if (isset($id)) {
         $softwareUser = SoftwareUser::find($id);
         if (isset($softwareUser)) {
             $complaints = Complaint::where('software_user_id', $id)->get();
             if (isset($complaints)) {
                 return json_encode(array('message' => 'found', 'complaints' => $complaints->toArray()));
             } else {
                 return json_encode(array('message' => 'empty'));
             }
         } else {
             return json_encode(array('message' => 'invalid'));
         }
     } else {
         return json_encode(array('message' => 'invalid'));
     }
 }
 public function listSoftwareUsers($status, $page)
 {
     $adminId = Session::get('admin_id');
     if (!isset($adminId)) {
         return json_encode(array('message' => 'not logged'));
     }
     $softwareUsers = SoftwareUser::where('status', '=', $status)->get();
     if (isset($softwareUsers) && count($softwareUsers) > 0) {
         return json_encode(array('message' => 'found', 'software_users' => $softwareUsers->toArray()));
     } else {
         return json_encode(array('message' => 'empty'));
     }
 }
 public function getSearchSoftwareUsers($key)
 {
     if (isset($key)) {
         $softwareUsers = SoftwareUser::where('name', 'like', '%' . $key . '%')->get();
         if (isset($softwareUsers)) {
             return json_encode(array('message' => 'found', 'software_users' => $softwareUsers->toArray()));
         } else {
             return json_encode(array('message' => 'empty'));
         }
     } else {
         return json_encode(array('message' => 'invalid'));
     }
 }