예제 #1
0
 public static function merge()
 {
     $rows = json_decode(Input::get('rows'));
     if (is_array($rows) && count($rows) > 0) {
         if (count($rows) < 2) {
             return Api::to(array('error', Lang::get('core.mergeerror'))) ?: \Response::json(array('result' => 'error', 'error' => Lang::get('core.mergeerror')));
         }
         $_merge_to = false;
         foreach ($rows as $i => $r) {
             if ($r != Confide::user()->id) {
                 $user = User::find($r);
                 if (!empty($user)) {
                     if (!$_merge_to) {
                         $_merge_to = $user;
                         continue;
                     }
                     if (!$user->merge($user)) {
                         return Api::to(array('error', 'Failed to delete ' . $r)) ?: \Response::json(array('result' => 'error', 'error' => 'Failed to delete ' . $r));
                     }
                 } else {
                     return Api::to(array('error', 'Could not find user ' . $r)) ?: \Response::json(array('result' => 'error', 'error' => 'Could not find user ' . $r));
                 }
             }
         }
     }
     if (!Api::make(array('success'))) {
         return \Response::json(array('result' => 'success'));
     }
 }
예제 #2
0
 public static function make($file, $data = array())
 {
     return Api::make($data) ?: View::make(self::path($file), $data);
 }