2

OK、読んで、メソッドと変数の PHP レイト スタティック バインディングについてある程度理解していると感じました。しかし、 Laravel 5 のこのコードの 28 行目からwhereIn、Laravel Collection メソッドであるwith を使用します。ここで何が起こっているのかわかりませんstatic::whereIn()。使用できるように、コレクションはどこにありますか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,
        ]);
    }
}
4

1 に答える 1

0

php.netの例:

class a
{
    static protected $test = "class a";

    public function static_test()
    {
        echo static::$test; // Results class b
        echo self::$test; // Results class a
    }
}

class b extends a
{
    static protected $test = "class b";
}

$obj = new b();
$obj->static_test();

static::whereIn()参照しTag::whereIn()ます。同じことが言えますstatic::create()

于 2016-06-30T07:06:30.037 に答える