Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
namespace Illuminate\Database\Eloquent\Relations;
4
 
5
use Illuminate\Database\Eloquent\Collection;
6
 
7
class HasMany extends HasOneOrMany
8
{
9
    /**
10
     * Get the results of the relationship.
11
     *
12
     * @return mixed
13
     */
14
    public function getResults()
15
    {
16
        return ! is_null($this->getParentKey())
17
                ? $this->query->get()
18
                : $this->related->newCollection();
19
    }
20
 
21
    /**
22
     * Initialize the relation on a set of models.
23
     *
24
     * @param  array  $models
25
     * @param  string  $relation
26
     * @return array
27
     */
28
    public function initRelation(array $models, $relation)
29
    {
30
        foreach ($models as $model) {
31
            $model->setRelation($relation, $this->related->newCollection());
32
        }
33
 
34
        return $models;
35
    }
36
 
37
    /**
38
     * Match the eagerly loaded results to their parents.
39
     *
40
     * @param  array  $models
41
     * @param  \Illuminate\Database\Eloquent\Collection  $results
42
     * @param  string  $relation
43
     * @return array
44
     */
45
    public function match(array $models, Collection $results, $relation)
46
    {
47
        return $this->matchMany($models, $results, $relation);
48
    }
49
}