@@ -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 | } |
@@ -6,60 +6,60 @@ |
||
| 6 | 6 | |
| 7 | 7 | class MorphPivot extends Pivot |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * The type of the polymorphic relation. |
|
| 11 | - * |
|
| 12 | - * Explicitly define this so it's not included in saved attributes. |
|
| 13 | - * |
|
| 14 | - * @var string |
|
| 15 | - */ |
|
| 16 | - protected $morphType; |
|
| 9 | + /** |
|
| 10 | + * The type of the polymorphic relation. |
|
| 11 | + * |
|
| 12 | + * Explicitly define this so it's not included in saved attributes. |
|
| 13 | + * |
|
| 14 | + * @var string |
|
| 15 | + */ |
|
| 16 | + protected $morphType; |
|
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * The value of the polymorphic relation. |
|
| 20 | - * |
|
| 21 | - * Explicitly define this so it's not included in saved attributes. |
|
| 22 | - * |
|
| 23 | - * @var string |
|
| 24 | - */ |
|
| 25 | - protected $morphClass; |
|
| 18 | + /** |
|
| 19 | + * The value of the polymorphic relation. |
|
| 20 | + * |
|
| 21 | + * Explicitly define this so it's not included in saved attributes. |
|
| 22 | + * |
|
| 23 | + * @var string |
|
| 24 | + */ |
|
| 25 | + protected $morphClass; |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Set the keys for a save update query. |
|
| 29 | - * |
|
| 30 | - * @param Query $query |
|
| 31 | - * @return Query |
|
| 32 | - */ |
|
| 33 | - protected function setKeysForSaveQuery(Query $query) |
|
| 34 | - { |
|
| 35 | - $query->where($this->morphType, $this->morphClass); |
|
| 27 | + /** |
|
| 28 | + * Set the keys for a save update query. |
|
| 29 | + * |
|
| 30 | + * @param Query $query |
|
| 31 | + * @return Query |
|
| 32 | + */ |
|
| 33 | + protected function setKeysForSaveQuery(Query $query) |
|
| 34 | + { |
|
| 35 | + $query->where($this->morphType, $this->morphClass); |
|
| 36 | 36 | |
| 37 | - return parent::setKeysForSaveQuery($query); |
|
| 38 | - } |
|
| 37 | + return parent::setKeysForSaveQuery($query); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * Set the morph type for the pivot. |
|
| 42 | - * |
|
| 43 | - * @param string $morphType |
|
| 44 | - * @return self |
|
| 45 | - */ |
|
| 46 | - public function setMorphType($morphType) |
|
| 47 | - { |
|
| 48 | - $this->morphType = $morphType; |
|
| 40 | + /** |
|
| 41 | + * Set the morph type for the pivot. |
|
| 42 | + * |
|
| 43 | + * @param string $morphType |
|
| 44 | + * @return self |
|
| 45 | + */ |
|
| 46 | + public function setMorphType($morphType) |
|
| 47 | + { |
|
| 48 | + $this->morphType = $morphType; |
|
| 49 | 49 | |
| 50 | - return $this; |
|
| 51 | - } |
|
| 50 | + return $this; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * Set the morph class for the pivot. |
|
| 55 | - * |
|
| 56 | - * @param string $morphClass |
|
| 57 | - * @return self |
|
| 58 | - */ |
|
| 59 | - public function setMorphClass($morphClass) |
|
| 60 | - { |
|
| 61 | - $this->morphClass = $morphClass; |
|
| 53 | + /** |
|
| 54 | + * Set the morph class for the pivot. |
|
| 55 | + * |
|
| 56 | + * @param string $morphClass |
|
| 57 | + * @return self |
|
| 58 | + */ |
|
| 59 | + public function setMorphClass($morphClass) |
|
| 60 | + { |
|
| 61 | + $this->morphClass = $morphClass; |
|
| 62 | 62 | |
| 63 | - return $this; |
|
| 64 | - } |
|
| 63 | + return $this; |
|
| 64 | + } |
|
| 65 | 65 | } |
@@ -6,50 +6,50 @@ |
||
| 6 | 6 | |
| 7 | 7 | class HasMany extends HasOneOrMany |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Get the results of the relationship. |
|
| 11 | - * |
|
| 12 | - * @param $relation |
|
| 13 | - * |
|
| 14 | - * @return mixed |
|
| 15 | - */ |
|
| 16 | - public function getResults($relation) |
|
| 17 | - { |
|
| 18 | - $results = $this->query->get(); |
|
| 19 | - |
|
| 20 | - $this->cacheRelation($results, $relation); |
|
| 21 | - |
|
| 22 | - return $results; |
|
| 23 | - } |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * Initialize the relation on a set of entities. |
|
| 27 | - * |
|
| 28 | - * @param array $entities |
|
| 29 | - * @param string $relation |
|
| 30 | - * @return array |
|
| 31 | - */ |
|
| 32 | - public function initRelation(array $entities, $relation) |
|
| 33 | - { |
|
| 34 | - foreach ($entities as $entity) { |
|
| 35 | - $entityWrapper = $this->factory->make($entity); |
|
| 36 | - |
|
| 37 | - $entityWrapper->setEntityAttribute($relation, $this->relatedMap->newCollection()); |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - return $entities; |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * Match the eagerly loaded results to their parents. |
|
| 45 | - * |
|
| 46 | - * @param array $entities |
|
| 47 | - * @param EntityCollection $results |
|
| 48 | - * @param string $relation |
|
| 49 | - * @return array |
|
| 50 | - */ |
|
| 51 | - public function match(array $entities, EntityCollection $results, $relation) |
|
| 52 | - { |
|
| 53 | - return $this->matchMany($entities, $results, $relation); |
|
| 54 | - } |
|
| 9 | + /** |
|
| 10 | + * Get the results of the relationship. |
|
| 11 | + * |
|
| 12 | + * @param $relation |
|
| 13 | + * |
|
| 14 | + * @return mixed |
|
| 15 | + */ |
|
| 16 | + public function getResults($relation) |
|
| 17 | + { |
|
| 18 | + $results = $this->query->get(); |
|
| 19 | + |
|
| 20 | + $this->cacheRelation($results, $relation); |
|
| 21 | + |
|
| 22 | + return $results; |
|
| 23 | + } |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * Initialize the relation on a set of entities. |
|
| 27 | + * |
|
| 28 | + * @param array $entities |
|
| 29 | + * @param string $relation |
|
| 30 | + * @return array |
|
| 31 | + */ |
|
| 32 | + public function initRelation(array $entities, $relation) |
|
| 33 | + { |
|
| 34 | + foreach ($entities as $entity) { |
|
| 35 | + $entityWrapper = $this->factory->make($entity); |
|
| 36 | + |
|
| 37 | + $entityWrapper->setEntityAttribute($relation, $this->relatedMap->newCollection()); |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + return $entities; |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * Match the eagerly loaded results to their parents. |
|
| 45 | + * |
|
| 46 | + * @param array $entities |
|
| 47 | + * @param EntityCollection $results |
|
| 48 | + * @param string $relation |
|
| 49 | + * @return array |
|
| 50 | + */ |
|
| 51 | + public function match(array $entities, EntityCollection $results, $relation) |
|
| 52 | + { |
|
| 53 | + return $this->matchMany($entities, $results, $relation); |
|
| 54 | + } |
|
| 55 | 55 | } |