【发布时间】:2016-11-02 02:56:56
【问题描述】:
好的,我阅读并感觉我对PHP后期静态绑定的方法和变量有所了解。但从 this code on Laravel 5 的第 28 行开始,它与 whereIn 一起使用,这是一个 Laravel 集合方法。我不明白这里发生了什么,@ 987654323@。集合在哪里,以便您可以使用whereIn()。
/**
* Add any tags needed from the list
*
* @param array $tags List of tags to check/add
*/
public static function addNeededTags(array $tags)
{
if (count($tags) === 0) {
return;
}
$found = static::whereIn('tag', $tags)->lists('tag')->all();
foreach (array_diff($tags, $found) as $tag) {
static::create([
'tag' => $tag,
'title' => $tag,
'subtitle' => 'Subtitle for '.$tag,
'page_image' => '',
'meta_description' => '',
'reverse_direction' => false,
]);
}
}
【问题讨论】:
-
这是使用模型中的wherIn(),而不是集合,扩展
Illuminate\Database\Eloquent\Model;中的Tag类。 -
谢谢。很高兴知道。
标签: php laravel late-static-binding