解析数据时出错:未定义的变量:缅甸人

发布于 2025-01-18 15:06:50 字数 876 浏览 0 评论 0原文

我确实从我的命令解析数据,在此之前,它获取该数据。当我想再做一次时,它就变成了一个错误。

我得到:

 Undefined variable: mystudents (View: /home/john/Documents/api4/api4/resources/views/emails/welcome.blade.php)`enter code here`

这是我的命令代码:

  foreach ($student as $mystudent) {

        $user = User::find($mystudent->user_id);
       Mail::to($user)->send(new WelcomeMail($mystudent));
   }
    
 
    Mail::to($user)->send(new WelcomeMail($student));
    echo "check email";

这是我的视图代码

@foreach ($mystudents as $student)
        
        <tr>
            <td>{{ $student->student_id }}</td>
            <td>{{ $student->name }}</td>
            <td>{{ $student->email }}</td>
            <td>{{ $student->phone }}</td>

我不确定我的代码是否正确。希望你能帮助我,先生。

I do parsing data from my command, before this, it gets that data. When I want to do it again, it becomes an error.

I got:

 Undefined variable: mystudents (View: /home/john/Documents/api4/api4/resources/views/emails/welcome.blade.php)`enter code here`

this is my code on command:

  foreach ($student as $mystudent) {

        $user = User::find($mystudent->user_id);
       Mail::to($user)->send(new WelcomeMail($mystudent));
   }
    
 
    Mail::to($user)->send(new WelcomeMail($student));
    echo "check email";

this is my code on view

@foreach ($mystudents as $student)
        
        <tr>
            <td>{{ $student->student_id }}</td>
            <td>{{ $student->name }}</td>
            <td>{{ $student->email }}</td>
            <td>{{ $student->phone }}</td>

I'm not sure that my code was correct. Hopefully, you help me, sir.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

写给空气的情书 2025-01-25 15:06:50

您正在命令以及视图中运行 foreach 循环。

此外,您还调用了 Mail send 方法两次。

我认为你只需要在你的命令中使用一次 foreach :

foreach ($student as $mystudent) {
    $user = User::find($mystudent->user_id);
    Mail::to($user)->send(new WelcomeMail($user));
}

你认为的代码可以是这样的:

<tr>
    <td>{{ $user->student_id }}</td>
    <td>{{ $user->name }}</td>
    <td>{{ $user->email }}</td>
    <td>{{ $user->phone }}</td>
</tr>

You are running a foreach loop in your command, as well as in your view.

Also, you are calling the Mail send method two times.

I think you only need a foreach once, in your command:

foreach ($student as $mystudent) {
    $user = User::find($mystudent->user_id);
    Mail::to($user)->send(new WelcomeMail($user));
}

The code in your view can be something like this:

<tr>
    <td>{{ $user->student_id }}</td>
    <td>{{ $user->name }}</td>
    <td>{{ $user->email }}</td>
    <td>{{ $user->phone }}</td>
</tr>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文