Skip to content
This repository was archived by the owner on Aug 22, 2023. It is now read-only.

Add header documentation for classes & traits that can be used in applications #12

Merged
merged 2 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
use MongoDB\BSON\ObjectID;
use MongoDB\Collection as MongoCollection;

/**
* @mixin MongoCollection
*/
class Collection
{
/**
Expand Down
3 changes: 3 additions & 0 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
use MongoDB\Database;
use Throwable;

/**
* @mixin Database
*/
class Connection extends BaseConnection
{
use ManagesTransactions;
Expand Down
2 changes: 1 addition & 1 deletion src/Eloquent/Casts/BinaryUuid.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function get($model, string $key, $value, array $attributes)
* @param string $key
* @param mixed $value
* @param array $attributes
* @return mixed
* @return Binary
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By reading the code, Binary is the only possible return type.

*/
public function set($model, string $key, $value, array $attributes)
{
Expand Down
3 changes: 3 additions & 0 deletions src/Eloquent/EmbedsRelations.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
use Jenssegers\Mongodb\Relations\EmbedsMany;
use Jenssegers\Mongodb\Relations\EmbedsOne;

/**
* Embeds relations for MongoDB models.
*/
trait EmbedsRelations
{
/**
Expand Down
4 changes: 4 additions & 0 deletions src/Eloquent/HybridRelations.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
use Jenssegers\Mongodb\Relations\MorphMany;
use Jenssegers\Mongodb\Relations\MorphTo;

/**
* Cross-database relationships between SQL and MongoDB.
* Use this trait in SQL models to define relationships with MongoDB models.
*/
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doc in Readme.

trait HybridRelations
{
/**
Expand Down
14 changes: 7 additions & 7 deletions src/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -788,9 +788,9 @@ public function raw($expression = null)
/**
* Append one or more values to an array.
*
* @param mixed $column
* @param mixed $value
* @param bool $unique
* @param string|array $column
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If not an array, $column is used as array key.

* @param mixed $value
* @param bool $unique
* @return int
*/
public function push($column, $value = null, $unique = false)
Expand Down Expand Up @@ -818,14 +818,14 @@ public function push($column, $value = null, $unique = false)
/**
* Remove one or more values from an array.
*
* @param mixed $column
* @param mixed $value
* @param string|array $column
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If not an array, $column is used as array key.

* @param mixed $value
* @return int
*/
public function pull($column, $value = null)
{
// Check if we passed an associative array.
$batch = (is_array($value) && array_keys($value) === range(0, count($value) - 1));
$batch = is_array($value) && array_is_list($value);

// If we are pulling multiple values, we need to use $pullAll.
$operator = $batch ? '$pullAll' : '$pull';
Expand All @@ -842,7 +842,7 @@ public function pull($column, $value = null)
/**
* Remove one or more fields.
*
* @param mixed $columns
* @param string|string[] $columns
* @return int
*/
public function drop($columns)
Expand Down