Пример #1
0
 public function store()
 {
     $dst = \Input::get('destination');
     $msg = \Input::get('message');
     $schedule = \Input::has('schedule') ? \Input::get('schedule') : null;
     if (\Input::get('state') == 0) {
         $e = array_map('trim', explode(',', $dst));
         foreach ($e as $key) {
             if ($key) {
                 $contact = Contact::where('Name', '=', $key)->first();
                 $group = Group::where('Name', '=', $key)->first();
                 if ($contact) {
                     return Outbox::create(['DestinationNumber' => $contact['Number'], 'SendingDateTime' => $schedule, 'TextDecoded' => $msg, 'CreatorID' => 'users.' . \Auth::user()->id]);
                 } else {
                     if ($group) {
                         return Outbox::SendToGroup($group->Name, $msg, $schedule);
                     } else {
                         return Outbox::create(['DestinationNumber' => $key, 'SendingDateTime' => $schedule, 'TextDecoded' => $msg, 'CreatorID' => 'users.' . \Auth::user()->id]);
                     }
                 }
             }
         }
     } else {
         return Outbox::create(['DestinationNumber' => $dst, 'TextDecoded' => $msg, 'CreatorID' => 'users.' . \Auth::user()->id]);
     }
 }
Пример #2
0
 public function update($id)
 {
     $db = Contact::find($id);
     $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;
     } else {
         $db->GroupID = '-1';
     }
     $db->save();
     return \Response::json(['id' => $db->ID]);
 }
Пример #3
0
 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!']);
         }
     }
 }