public function prepareMsgText() { $this->type_id = Input::get('type_id'); $columns = MessageTypeColums::where('type_id', '=', $this->type_id)->orderBy('id', 'ASC')->get(); $arr = array(); foreach ($columns as $column) { $id = $column->id; $key = Input::get('key' . $id); $value = Input::get('value' . $id); $arr[$key] = $value; } $this->message_arr = $arr; $this->message = json_encode($arr, JSON_PRETTY_PRINT); // print_r($this->message_arr); }
public function postDelMsgType() { $id = Input::get('id'); $validator = Validator::make(array('id' => $id), $this->validate_id_arr); if ($validator->fails()) { return json_encode(array(false, "Invalid notification type ID")); // return Redirect::to('message-types') // ->with('msg', 'Invalid notification type ID') // ->with('state', '-1'); } $type_id = $id; // $checkUsed = $this->checkMsgTypeUsed($type_id); // if ($checkUsed) { // return "Can't delete Notification Type.It's used"; // } $type = MessageType::find($type_id); if (!$type) { return json_encode(array(false, "Type isn't found")); } try { MessageTypeColums::where('type_id', '=', $type_id)->delete(); $type->delete(); return json_encode(array(true, "Notification type deleted successfully")); // return Redirect::to('message-types') // ->with('msg', 'Notification type deleted successfully'); } catch (Exception $e) { return json_encode(array(false, "Can\\'t delete notification type")); // return Redirect::to('message-types') // ->with('msg', 'Can\'t delete notification type') // ->with('state', '-1'); } }