Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从数组中查询Laravel_Php_Mysql_Laravel_Eloquent - Fatal编程技术网

Php 从数组中查询Laravel

Php 从数组中查询Laravel,php,mysql,laravel,eloquent,Php,Mysql,Laravel,Eloquent,“我的用户”可以在注释中标记其他用户,这将返回用户名和以下标记: <span class="atwho-inserted" data-atwho-at-query="@josh"><a href="/profile/joshuaTest" data-type="mentionable" data-id="undefined" data-name="joshuaTest">joshuaTest</a></span> <span class="a

“我的用户”可以在注释中标记其他用户,这将返回用户名和以下标记:

<span class="atwho-inserted" data-atwho-at-query="@josh"><a href="/profile/joshuaTest" data-type="mentionable" data-id="undefined" data-name="joshuaTest">joshuaTest</a></span>
<span class="atwho-inserted" data-atwho-at-query="@jish"><a href="/profile/jishy" data-type="mentionable" data-id="undefined" data-name="jishy">jishy</a></span>
$matches将为我提供准确的用户名,我可以使用这些用户名查询数据库

然后,我想在foreach中执行如下操作,我想知道是否可以使用匹配用户名的结果循环此查询

foreach($matches as $match)
    {
        $j = User::whereUsername($match[0,1,2,3 or whatever here (Until it equals $t)])->first();
    }
然后通过Notifynder包通知通过用户名找到的用户:

Notifynder::category('userpropped')
    ->from(1)
    ->to(//UserID from above)
    ->url('/notifications')
    ->send();
本质上,我希望从用户的用户名中获取用户,获取他们的ID,并在将其传递给notifynder函数时循环使用它们

这是我能做到的,还是我以一种不正确的方式做事


谢谢

需要背景。什么是
$matches
?它是一系列html元素吗?正则表达式中的
数据名
属性有什么问题?对不起,您到底遇到了什么问题?您应该尝试提供一些示例输入、预期输出以及不起作用的地方。将更新我的问题,抱歉!您需要像User::where('name','=','joshuaTest');where子句将为您遍历所有记录。
Notifynder::category('userpropped')
    ->from(1)
    ->to(//UserID from above)
    ->url('/notifications')
    ->send();