@@ -11,70 +11,70 @@ |
||
11 | 11 | */ |
12 | 12 | class IlluminateDBAdapter implements DBAdapter |
13 | 13 | { |
14 | - /** |
|
15 | - * @var Connection |
|
16 | - */ |
|
17 | - protected $connection; |
|
14 | + /** |
|
15 | + * @var Connection |
|
16 | + */ |
|
17 | + protected $connection; |
|
18 | 18 | |
19 | - /** |
|
20 | - * IlluminateDBAdapter constructor. |
|
21 | - * @param Connection $connection |
|
22 | - */ |
|
23 | - public function __construct(Connection $connection) |
|
24 | - { |
|
25 | - $this->connection = $connection; |
|
26 | - } |
|
19 | + /** |
|
20 | + * IlluminateDBAdapter constructor. |
|
21 | + * @param Connection $connection |
|
22 | + */ |
|
23 | + public function __construct(Connection $connection) |
|
24 | + { |
|
25 | + $this->connection = $connection; |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * Return a new Query instance for this driver |
|
30 | - * |
|
31 | - * @return QueryAdapter |
|
32 | - */ |
|
33 | - public function getQuery() |
|
34 | - { |
|
35 | - $connection = $this->connection; |
|
28 | + /** |
|
29 | + * Return a new Query instance for this driver |
|
30 | + * |
|
31 | + * @return QueryAdapter |
|
32 | + */ |
|
33 | + public function getQuery() |
|
34 | + { |
|
35 | + $connection = $this->connection; |
|
36 | 36 | |
37 | - $grammar = $connection->getQueryGrammar(); |
|
37 | + $grammar = $connection->getQueryGrammar(); |
|
38 | 38 | |
39 | - $queryBuilder = new QueryBuilder($connection, $grammar, $connection->getPostProcessor()); |
|
39 | + $queryBuilder = new QueryBuilder($connection, $grammar, $connection->getPostProcessor()); |
|
40 | 40 | |
41 | - return new IlluminateQueryAdapter($queryBuilder); |
|
42 | - } |
|
41 | + return new IlluminateQueryAdapter($queryBuilder); |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * Get the date format supported by the current connection |
|
46 | - * |
|
47 | - * @return string |
|
48 | - */ |
|
49 | - public function getDateFormat() |
|
50 | - { |
|
51 | - return $this->connection->getQueryGrammar()->getDateFormat(); |
|
52 | - } |
|
44 | + /** |
|
45 | + * Get the date format supported by the current connection |
|
46 | + * |
|
47 | + * @return string |
|
48 | + */ |
|
49 | + public function getDateFormat() |
|
50 | + { |
|
51 | + return $this->connection->getQueryGrammar()->getDateFormat(); |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * Start a DB transaction on driver that supports it. |
|
56 | - * @return void |
|
57 | - */ |
|
58 | - public function beginTransaction() |
|
59 | - { |
|
60 | - $this->connection->beginTransaction(); |
|
61 | - } |
|
54 | + /** |
|
55 | + * Start a DB transaction on driver that supports it. |
|
56 | + * @return void |
|
57 | + */ |
|
58 | + public function beginTransaction() |
|
59 | + { |
|
60 | + $this->connection->beginTransaction(); |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * Commit a DB transaction on driver that supports it. |
|
65 | - * @return void |
|
66 | - */ |
|
67 | - public function commit() |
|
68 | - { |
|
69 | - $this->connection->commit(); |
|
70 | - } |
|
63 | + /** |
|
64 | + * Commit a DB transaction on driver that supports it. |
|
65 | + * @return void |
|
66 | + */ |
|
67 | + public function commit() |
|
68 | + { |
|
69 | + $this->connection->commit(); |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * Rollback a DB transaction |
|
74 | - * @return void |
|
75 | - */ |
|
76 | - public function rollback() |
|
77 | - { |
|
78 | - $this->connection->rollBack(); |
|
79 | - } |
|
72 | + /** |
|
73 | + * Rollback a DB transaction |
|
74 | + * @return void |
|
75 | + */ |
|
76 | + public function rollback() |
|
77 | + { |
|
78 | + $this->connection->rollBack(); |
|
79 | + } |
|
80 | 80 | } |
@@ -4,32 +4,32 @@ |
||
4 | 4 | |
5 | 5 | class Manager |
6 | 6 | { |
7 | - /** |
|
8 | - * @var DriverInterface[] |
|
9 | - */ |
|
10 | - protected $drivers = []; |
|
7 | + /** |
|
8 | + * @var DriverInterface[] |
|
9 | + */ |
|
10 | + protected $drivers = []; |
|
11 | 11 | |
12 | - /** |
|
13 | - * Add a Mapping Driver |
|
14 | - * |
|
15 | - * @param DriverInterface $driver |
|
16 | - */ |
|
17 | - public function addDriver(DriverInterface $driver) |
|
18 | - { |
|
19 | - $this->drivers[$driver->getName()] = $driver; |
|
20 | - } |
|
12 | + /** |
|
13 | + * Add a Mapping Driver |
|
14 | + * |
|
15 | + * @param DriverInterface $driver |
|
16 | + */ |
|
17 | + public function addDriver(DriverInterface $driver) |
|
18 | + { |
|
19 | + $this->drivers[$driver->getName()] = $driver; |
|
20 | + } |
|
21 | 21 | |
22 | - /** |
|
23 | - * Get the DBAdapter |
|
24 | - * |
|
25 | - * @param string $driver |
|
26 | - * @param string $connection connection name for drivers supporting multiple connection. |
|
27 | - * @return DriverInterface|void |
|
28 | - */ |
|
29 | - public function getAdapter($driver, $connection = null) |
|
30 | - { |
|
31 | - if (array_key_exists($driver, $this->drivers)) { |
|
32 | - return $this->drivers[$driver]->getAdapter($connection); |
|
33 | - } |
|
34 | - } |
|
22 | + /** |
|
23 | + * Get the DBAdapter |
|
24 | + * |
|
25 | + * @param string $driver |
|
26 | + * @param string $connection connection name for drivers supporting multiple connection. |
|
27 | + * @return DriverInterface|void |
|
28 | + */ |
|
29 | + public function getAdapter($driver, $connection = null) |
|
30 | + { |
|
31 | + if (array_key_exists($driver, $this->drivers)) { |
|
32 | + return $this->drivers[$driver]->getAdapter($connection); |
|
33 | + } |
|
34 | + } |
|
35 | 35 | } |
@@ -6,28 +6,28 @@ |
||
6 | 6 | |
7 | 7 | class CapsuleConnectionProvider |
8 | 8 | { |
9 | - /** |
|
10 | - * @var Capsule |
|
11 | - */ |
|
12 | - protected $capsule; |
|
9 | + /** |
|
10 | + * @var Capsule |
|
11 | + */ |
|
12 | + protected $capsule; |
|
13 | 13 | |
14 | - /** |
|
15 | - * CapsuleConnectionProvider constructor. |
|
16 | - * @param Capsule $capsule |
|
17 | - */ |
|
18 | - public function __construct(Capsule $capsule) |
|
19 | - { |
|
20 | - $this->capsule = $capsule; |
|
21 | - } |
|
14 | + /** |
|
15 | + * CapsuleConnectionProvider constructor. |
|
16 | + * @param Capsule $capsule |
|
17 | + */ |
|
18 | + public function __construct(Capsule $capsule) |
|
19 | + { |
|
20 | + $this->capsule = $capsule; |
|
21 | + } |
|
22 | 22 | |
23 | - /** |
|
24 | - * Get a Database connection object |
|
25 | - * |
|
26 | - * @param $name |
|
27 | - * @return \Illuminate\Database\Connection |
|
28 | - */ |
|
29 | - public function connection($name = null) |
|
30 | - { |
|
31 | - return $this->capsule->getConnection($name); |
|
32 | - } |
|
23 | + /** |
|
24 | + * Get a Database connection object |
|
25 | + * |
|
26 | + * @param $name |
|
27 | + * @return \Illuminate\Database\Connection |
|
28 | + */ |
|
29 | + public function connection($name = null) |
|
30 | + { |
|
31 | + return $this->capsule->getConnection($name); |
|
32 | + } |
|
33 | 33 | } |
@@ -4,16 +4,16 @@ |
||
4 | 4 | |
5 | 5 | interface DriverInterface |
6 | 6 | { |
7 | - /** |
|
8 | - * Return the name of the driver |
|
9 | - * @return string |
|
10 | - */ |
|
11 | - public function getName(); |
|
7 | + /** |
|
8 | + * Return the name of the driver |
|
9 | + * @return string |
|
10 | + */ |
|
11 | + public function getName(); |
|
12 | 12 | |
13 | - /** |
|
14 | - * Get Analogue DB Adapter |
|
15 | - * @param string $connection connection name for drivers supporting multiple connections |
|
16 | - * @return \Analogue\ORM\Drivers\DBAdapter |
|
17 | - */ |
|
18 | - public function getAdapter($connection = null); |
|
13 | + /** |
|
14 | + * Get Analogue DB Adapter |
|
15 | + * @param string $connection connection name for drivers supporting multiple connections |
|
16 | + * @return \Analogue\ORM\Drivers\DBAdapter |
|
17 | + */ |
|
18 | + public function getAdapter($connection = null); |
|
19 | 19 | } |
@@ -4,42 +4,42 @@ |
||
4 | 4 | |
5 | 5 | class IlluminateDriver implements DriverInterface |
6 | 6 | { |
7 | - /** |
|
8 | - * The Illuminate Connection Provider |
|
9 | - * |
|
10 | - * @var CapsuleConnectionProvider|IlluminateConnectionProvider |
|
11 | - */ |
|
12 | - protected $connectionProvider; |
|
7 | + /** |
|
8 | + * The Illuminate Connection Provider |
|
9 | + * |
|
10 | + * @var CapsuleConnectionProvider|IlluminateConnectionProvider |
|
11 | + */ |
|
12 | + protected $connectionProvider; |
|
13 | 13 | |
14 | - /** |
|
15 | - * IlluminateDriver constructor. |
|
16 | - * @param $connectionProvider |
|
17 | - */ |
|
18 | - public function __construct($connectionProvider) |
|
19 | - { |
|
20 | - $this->connectionProvider = $connectionProvider; |
|
21 | - } |
|
14 | + /** |
|
15 | + * IlluminateDriver constructor. |
|
16 | + * @param $connectionProvider |
|
17 | + */ |
|
18 | + public function __construct($connectionProvider) |
|
19 | + { |
|
20 | + $this->connectionProvider = $connectionProvider; |
|
21 | + } |
|
22 | 22 | |
23 | - /** |
|
24 | - * Return the name of the driver |
|
25 | - * |
|
26 | - * @return string |
|
27 | - */ |
|
28 | - public function getName() |
|
29 | - { |
|
30 | - return 'illuminate'; |
|
31 | - } |
|
23 | + /** |
|
24 | + * Return the name of the driver |
|
25 | + * |
|
26 | + * @return string |
|
27 | + */ |
|
28 | + public function getName() |
|
29 | + { |
|
30 | + return 'illuminate'; |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * Get Analogue DBAdapter |
|
35 | - * |
|
36 | - * @param string|null $connection |
|
37 | - * @return IlluminateDBAdapter |
|
38 | - */ |
|
39 | - public function getAdapter($connection = null) |
|
40 | - { |
|
41 | - $connection = $this->connectionProvider->connection($connection); |
|
33 | + /** |
|
34 | + * Get Analogue DBAdapter |
|
35 | + * |
|
36 | + * @param string|null $connection |
|
37 | + * @return IlluminateDBAdapter |
|
38 | + */ |
|
39 | + public function getAdapter($connection = null) |
|
40 | + { |
|
41 | + $connection = $this->connectionProvider->connection($connection); |
|
42 | 42 | |
43 | - return new IlluminateDBAdapter($connection); |
|
44 | - } |
|
43 | + return new IlluminateDBAdapter($connection); |
|
44 | + } |
|
45 | 45 | } |
@@ -4,38 +4,38 @@ |
||
4 | 4 | |
5 | 5 | interface DBAdapter |
6 | 6 | { |
7 | - /** |
|
8 | - * Return's Driver specific Query Implementation |
|
9 | - * |
|
10 | - * @return \Analogue\ORM\Drivers\QueryAdapter|\Analogue\ORM\Drivers\IlluminateQueryAdapter |
|
11 | - */ |
|
12 | - public function getQuery(); |
|
7 | + /** |
|
8 | + * Return's Driver specific Query Implementation |
|
9 | + * |
|
10 | + * @return \Analogue\ORM\Drivers\QueryAdapter|\Analogue\ORM\Drivers\IlluminateQueryAdapter |
|
11 | + */ |
|
12 | + public function getQuery(); |
|
13 | 13 | |
14 | - /** |
|
15 | - * Return the Date format used on this adapter |
|
16 | - * |
|
17 | - * @return string |
|
18 | - */ |
|
19 | - public function getDateFormat(); |
|
14 | + /** |
|
15 | + * Return the Date format used on this adapter |
|
16 | + * |
|
17 | + * @return string |
|
18 | + */ |
|
19 | + public function getDateFormat(); |
|
20 | 20 | |
21 | - /** |
|
22 | - * Start a DB transaction on driver that supports it. |
|
23 | - * |
|
24 | - * @return void |
|
25 | - */ |
|
26 | - public function beginTransaction(); |
|
21 | + /** |
|
22 | + * Start a DB transaction on driver that supports it. |
|
23 | + * |
|
24 | + * @return void |
|
25 | + */ |
|
26 | + public function beginTransaction(); |
|
27 | 27 | |
28 | - /** |
|
29 | - * Commit a DB transaction on driver that supports it. |
|
30 | - * |
|
31 | - * @return void |
|
32 | - */ |
|
33 | - public function commit(); |
|
28 | + /** |
|
29 | + * Commit a DB transaction on driver that supports it. |
|
30 | + * |
|
31 | + * @return void |
|
32 | + */ |
|
33 | + public function commit(); |
|
34 | 34 | |
35 | - /** |
|
36 | - * Rollback a DB transaction on driver that supports it. |
|
37 | - * |
|
38 | - * @return void |
|
39 | - */ |
|
40 | - public function rollback(); |
|
35 | + /** |
|
36 | + * Rollback a DB transaction on driver that supports it. |
|
37 | + * |
|
38 | + * @return void |
|
39 | + */ |
|
40 | + public function rollback(); |
|
41 | 41 | } |
@@ -4,17 +4,17 @@ |
||
4 | 4 | |
5 | 5 | interface Mappable |
6 | 6 | { |
7 | - /** |
|
8 | - * Set the object attribute raw values (hydration) |
|
9 | - * |
|
10 | - * @param array $attributes |
|
11 | - */ |
|
12 | - public function setEntityAttributes(array $attributes); |
|
7 | + /** |
|
8 | + * Set the object attribute raw values (hydration) |
|
9 | + * |
|
10 | + * @param array $attributes |
|
11 | + */ |
|
12 | + public function setEntityAttributes(array $attributes); |
|
13 | 13 | |
14 | - /** |
|
15 | - * Get the raw object's values. |
|
16 | - * |
|
17 | - * @return array |
|
18 | - */ |
|
19 | - public function getEntityAttributes(); |
|
14 | + /** |
|
15 | + * Get the raw object's values. |
|
16 | + * |
|
17 | + * @return array |
|
18 | + */ |
|
19 | + public function getEntityAttributes(); |
|
20 | 20 | } |
@@ -17,114 +17,114 @@ |
||
17 | 17 | */ |
18 | 18 | class Analogue |
19 | 19 | { |
20 | - /** |
|
21 | - * @var self |
|
22 | - */ |
|
23 | - protected static $instance; |
|
24 | - |
|
25 | - /** |
|
26 | - * @var Manager |
|
27 | - */ |
|
28 | - protected static $manager; |
|
29 | - |
|
30 | - /** |
|
31 | - * @var Capsule |
|
32 | - */ |
|
33 | - protected static $capsule; |
|
34 | - |
|
35 | - /** |
|
36 | - * @var bool |
|
37 | - */ |
|
38 | - protected static $booted = false; |
|
39 | - |
|
40 | - /** |
|
41 | - * Analogue constructor. |
|
42 | - * @param array $connection |
|
43 | - */ |
|
44 | - public function __construct(array $connection) |
|
45 | - { |
|
46 | - if (!static::$booted) { |
|
47 | - static::$capsule = new Capsule; |
|
48 | - |
|
49 | - $this->addConnection($connection); |
|
50 | - |
|
51 | - $this->boot(); |
|
52 | - } |
|
53 | - } |
|
54 | - |
|
55 | - /** |
|
56 | - * Boot Analogue |
|
57 | - * |
|
58 | - * @return Analogue |
|
59 | - */ |
|
60 | - public function boot() |
|
61 | - { |
|
62 | - if (static::$booted) { |
|
63 | - return $this; |
|
64 | - } |
|
65 | - |
|
66 | - $dispatcher = new Dispatcher; |
|
67 | - |
|
68 | - $connectionProvider = new CapsuleConnectionProvider(static::$capsule); |
|
69 | - |
|
70 | - $illuminate = new IlluminateDriver($connectionProvider); |
|
71 | - |
|
72 | - $driverManager = new DriverManager; |
|
73 | - |
|
74 | - $driverManager->addDriver($illuminate); |
|
75 | - |
|
76 | - static::$manager = new Manager($driverManager, $dispatcher); |
|
20 | + /** |
|
21 | + * @var self |
|
22 | + */ |
|
23 | + protected static $instance; |
|
24 | + |
|
25 | + /** |
|
26 | + * @var Manager |
|
27 | + */ |
|
28 | + protected static $manager; |
|
29 | + |
|
30 | + /** |
|
31 | + * @var Capsule |
|
32 | + */ |
|
33 | + protected static $capsule; |
|
34 | + |
|
35 | + /** |
|
36 | + * @var bool |
|
37 | + */ |
|
38 | + protected static $booted = false; |
|
39 | + |
|
40 | + /** |
|
41 | + * Analogue constructor. |
|
42 | + * @param array $connection |
|
43 | + */ |
|
44 | + public function __construct(array $connection) |
|
45 | + { |
|
46 | + if (!static::$booted) { |
|
47 | + static::$capsule = new Capsule; |
|
48 | + |
|
49 | + $this->addConnection($connection); |
|
50 | + |
|
51 | + $this->boot(); |
|
52 | + } |
|
53 | + } |
|
54 | + |
|
55 | + /** |
|
56 | + * Boot Analogue |
|
57 | + * |
|
58 | + * @return Analogue |
|
59 | + */ |
|
60 | + public function boot() |
|
61 | + { |
|
62 | + if (static::$booted) { |
|
63 | + return $this; |
|
64 | + } |
|
65 | + |
|
66 | + $dispatcher = new Dispatcher; |
|
67 | + |
|
68 | + $connectionProvider = new CapsuleConnectionProvider(static::$capsule); |
|
69 | + |
|
70 | + $illuminate = new IlluminateDriver($connectionProvider); |
|
71 | + |
|
72 | + $driverManager = new DriverManager; |
|
73 | + |
|
74 | + $driverManager->addDriver($illuminate); |
|
75 | + |
|
76 | + static::$manager = new Manager($driverManager, $dispatcher); |
|
77 | 77 | |
78 | - static::$instance = $this; |
|
79 | - |
|
80 | - static::$booted = true; |
|
81 | - |
|
82 | - return $this; |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * Add a connection array to Capsule |
|
87 | - * |
|
88 | - * @param array $config |
|
89 | - * @param string $name |
|
90 | - */ |
|
91 | - public function addConnection($config, $name = 'default') |
|
92 | - { |
|
93 | - static::$capsule->addConnection($config, $name); |
|
94 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * Get a Database connection object |
|
98 | - * |
|
99 | - * @param $name |
|
100 | - * @return \Illuminate\Database\Connection |
|
101 | - */ |
|
102 | - public function connection($name = null) |
|
103 | - { |
|
104 | - return static::$capsule->getConnection($name); |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * Dynamically handle static calls to the instance, Facade Style. |
|
109 | - * |
|
110 | - * @param string $method |
|
111 | - * @param array $parameters |
|
112 | - * @return mixed |
|
113 | - */ |
|
114 | - public static function __callStatic($method, $parameters) |
|
115 | - { |
|
116 | - return call_user_func_array([static::$instance, $method], $parameters); |
|
117 | - } |
|
118 | - |
|
119 | - /** |
|
120 | - * Dynamically handle calls to the Analogue Manager instance. |
|
121 | - * |
|
122 | - * @param string $method |
|
123 | - * @param array $parameters |
|
124 | - * @return mixed |
|
125 | - */ |
|
126 | - public function __call($method, $parameters) |
|
127 | - { |
|
128 | - return call_user_func_array([static::$manager, $method], $parameters); |
|
129 | - } |
|
78 | + static::$instance = $this; |
|
79 | + |
|
80 | + static::$booted = true; |
|
81 | + |
|
82 | + return $this; |
|
83 | + } |
|
84 | + |
|
85 | + /** |
|
86 | + * Add a connection array to Capsule |
|
87 | + * |
|
88 | + * @param array $config |
|
89 | + * @param string $name |
|
90 | + */ |
|
91 | + public function addConnection($config, $name = 'default') |
|
92 | + { |
|
93 | + static::$capsule->addConnection($config, $name); |
|
94 | + } |
|
95 | + |
|
96 | + /** |
|
97 | + * Get a Database connection object |
|
98 | + * |
|
99 | + * @param $name |
|
100 | + * @return \Illuminate\Database\Connection |
|
101 | + */ |
|
102 | + public function connection($name = null) |
|
103 | + { |
|
104 | + return static::$capsule->getConnection($name); |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * Dynamically handle static calls to the instance, Facade Style. |
|
109 | + * |
|
110 | + * @param string $method |
|
111 | + * @param array $parameters |
|
112 | + * @return mixed |
|
113 | + */ |
|
114 | + public static function __callStatic($method, $parameters) |
|
115 | + { |
|
116 | + return call_user_func_array([static::$instance, $method], $parameters); |
|
117 | + } |
|
118 | + |
|
119 | + /** |
|
120 | + * Dynamically handle calls to the Analogue Manager instance. |
|
121 | + * |
|
122 | + * @param string $method |
|
123 | + * @param array $parameters |
|
124 | + * @return mixed |
|
125 | + */ |
|
126 | + public function __call($method, $parameters) |
|
127 | + { |
|
128 | + return call_user_func_array([static::$manager, $method], $parameters); |
|
129 | + } |
|
130 | 130 | } |
@@ -6,58 +6,58 @@ |
||
6 | 6 | |
7 | 7 | class HasOne extends HasOneOrMany |
8 | 8 | { |
9 | - /** |
|
10 | - * Get the results of the relationship. |
|
11 | - * |
|
12 | - * @param $relation |
|
13 | - * @return mixed |
|
14 | - */ |
|
15 | - public function getResults($relation) |
|
16 | - { |
|
17 | - $result = $this->query->first(); |
|
18 | - |
|
19 | - $this->cacheRelation($result, $relation); |
|
20 | - |
|
21 | - return $result; |
|
22 | - } |
|
23 | - |
|
24 | - /** |
|
25 | - * Get the results of the relationship. |
|
26 | - * |
|
27 | - * @return mixed |
|
28 | - */ |
|
29 | - public function fetch() |
|
30 | - { |
|
31 | - return $this->query->first(); |
|
32 | - } |
|
33 | - |
|
34 | - |
|
35 | - /** |
|
36 | - * Initialize the relation on a set of entities. |
|
37 | - * |
|
38 | - * @param \Analogue\ORM\Entity[] $entities |
|
39 | - * @param string $relation |
|
40 | - * @return array |
|
41 | - */ |
|
42 | - public function initRelation(array $entities, $relation) |
|
43 | - { |
|
44 | - foreach ($entities as $entity) { |
|
45 | - $entity->setEntityAttribute($relation, null); |
|
46 | - } |
|
47 | - |
|
48 | - return $entities; |
|
49 | - } |
|
50 | - |
|
51 | - /** |
|
52 | - * Match the eagerly loaded results to their parents. |
|
53 | - * |
|
54 | - * @param \Analogue\ORM\Entity[] $entities |
|
55 | - * @param EntityCollection $results |
|
56 | - * @param string $relation |
|
57 | - * @return array |
|
58 | - */ |
|
59 | - public function match(array $entities, EntityCollection $results, $relation) |
|
60 | - { |
|
61 | - return $this->matchOne($entities, $results, $relation); |
|
62 | - } |
|
9 | + /** |
|
10 | + * Get the results of the relationship. |
|
11 | + * |
|
12 | + * @param $relation |
|
13 | + * @return mixed |
|
14 | + */ |
|
15 | + public function getResults($relation) |
|
16 | + { |
|
17 | + $result = $this->query->first(); |
|
18 | + |
|
19 | + $this->cacheRelation($result, $relation); |
|
20 | + |
|
21 | + return $result; |
|
22 | + } |
|
23 | + |
|
24 | + /** |
|
25 | + * Get the results of the relationship. |
|
26 | + * |
|
27 | + * @return mixed |
|
28 | + */ |
|
29 | + public function fetch() |
|
30 | + { |
|
31 | + return $this->query->first(); |
|
32 | + } |
|
33 | + |
|
34 | + |
|
35 | + /** |
|
36 | + * Initialize the relation on a set of entities. |
|
37 | + * |
|
38 | + * @param \Analogue\ORM\Entity[] $entities |
|
39 | + * @param string $relation |
|
40 | + * @return array |
|
41 | + */ |
|
42 | + public function initRelation(array $entities, $relation) |
|
43 | + { |
|
44 | + foreach ($entities as $entity) { |
|
45 | + $entity->setEntityAttribute($relation, null); |
|
46 | + } |
|
47 | + |
|
48 | + return $entities; |
|
49 | + } |
|
50 | + |
|
51 | + /** |
|
52 | + * Match the eagerly loaded results to their parents. |
|
53 | + * |
|
54 | + * @param \Analogue\ORM\Entity[] $entities |
|
55 | + * @param EntityCollection $results |
|
56 | + * @param string $relation |
|
57 | + * @return array |
|
58 | + */ |
|
59 | + public function match(array $entities, EntityCollection $results, $relation) |
|
60 | + { |
|
61 | + return $this->matchOne($entities, $results, $relation); |
|
62 | + } |
|
63 | 63 | } |