Ejemplo n.º 1
0
 /**
  * Api function for get contact detail.
  * 
  * @param number $id
  * @return Response
  */
 public function getContactDetail($id = 0)
 {
     // Validator contact id.
     $valids = Validator::make(['id' => $id], ['id' => 'required|min:1'], SNSContactsHelper::getMessage());
     // Check validator
     if ($valids->fails()) {
         return Response::json(array('status' => 'error', 'data' => $valids->messages()), 500);
     }
     // Get contact detail
     $record = Contact::whereRaw('id = ? AND status = ?', array($id, true))->get();
     return Response::json(array('status' => 'success', 'data' => $record));
 }
Ejemplo n.º 2
0
 /**
  * Api function for add new user
  * 
  * @return Response
  */
 public function postUser()
 {
     $data = post();
     /* Validator request params */
     $valids = Validator::make($data, ['name' => 'required', 'email' => 'required|email|between:2,64', 'password' => 'required|min:2', 'password_confirmation' => 'required|confirmed']);
     if ($valids->fails()) {
         return SNSContactsHelper::getErrorMsg($valids->messages());
     }
     $automaticActivation = UserSettings::get('activate_mode') == UserSettings::ACTIVATE_AUTO;
     $user = Auth::register($data, $automaticActivation);
     /*
      * Automatically activated or not required, log the user in
      */
     if ($automaticActivation || !$requireActivation) {
         Auth::login($user);
     }
     return SNSContactsHelper::getSuccess($user);
 }