我想在给定文本输入的情况下从控制器内的数据库表发送一组电子邮件

时间:2018-03-23 16:06:02

标签: javascript php laravel-5.4

这是刀片视图中将阵列推送到控制器的代码 它的工作方式是,用户键入A或P表示缺席和迟到,如果当前[]的输入值为每个学生的A但是未能从输入中检索学生ID,则需要发送电子邮件。 / p>

function addRow(data,index) {
        var table = document.getElementById('studentList');
        var rowCount = table.rows.length;
        var row = table.insertRow(rowCount);

        var cell2 = row.insertCell(0);
        var id = document.createElement("label");

        id.innerHTML=data['id'];
        cell2.appendChild(id);
        var id = document.createElement("input");
        id.name="id[]";
        id.value=data['id'];
        id.type="hidden";
        cell2.appendChild(id);

        var cell3 = row.insertCell(1);
        var name = document.createElement("label");
        name.innerHTML=data['name'];
        cell3.appendChild(name);

        var cell4 = row.insertCell(2);
        var attendance = document.createElement("input");
        attendance.type = "text";
        attendance.placeholder = "Class Attendance";
        attendance.name="present[]";
        attendance.size="5";
        cell4.appendChild(attendance);

    };

然后我的控制器到目前为止

 public function saveAttendance(Request $request)
{
    $student_id = $request->get('id');
    $class_id = $request->get('class_id');
    $term = $request->get('term');
    $teacher_id = $request->get('teacher_id');
    $status = $request->get('present');
    $isSendSMS = $request->get('isSendSMS');

    if ($isSendSMS == null)
        {
            return redirect()->back()->with('success', 'Attendance List Added Successfully');
        }
        else
        {
            foreach ($status as $s)
            {
                $absent = ($s == "A");
                if($absent)
                     echo 'absent';
                else
                  echo 'other';
            }

        }
}

0 个答案:

没有答案