public function store()
 {
     $db = new Contact();
     $db->Name = \Input::get('name');
     $db->Number = \Input::get('number');
     if (\Input::has('group')) {
         $dbgroup = Group::firstOrCreate(['Name' => \Input::get('group')]);
         $db->GroupID = $dbgroup->ID;
     }
     $db->save();
     return \Response::json(['id' => $db->ID]);
 }
 public function postContact()
 {
     if (\Input::get('action') == 'delete') {
         $db = Contact::destroy(\Input::get('ID'));
         if ($db) {
             return \Response::json(['success' => 1, 'message' => 'Hapus data berhasil!']);
         } else {
             return \Response::json(['success' => 0, 'message' => 'Hapus data gagal!']);
         }
     } else {
         if (\Input::has('ID')) {
             $status = 'Edit';
             $db = Contact::find(\Input::get('ID'));
         } else {
             $status = 'Tambah';
             $db = new Contact();
         }
         $db->Name = \Input::get('Name');
         $db->Number = \Input::get('Number');
         $db->GroupID = \Input::get('GroupID');
         // if(\Input::has('GroupID')){
         // 	$dbgroup = Group::firstOrCreate(['Name'=>\Input::get('GroupID')]);
         // 	$db->GroupID = $dbgroup->ID;
         // }
         $db->save();
         if ($db->ID) {
             return \Response::json(['success' => 1, 'message' => $status . ' data berhasil!']);
         } else {
             return \Response::json(['success' => 0, 'message' => $status . ' data gagal!']);
         }
     }
 }