jenssegers / jenssegers/model

Add append function

Open
#47 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
394
Forks
59
PR merge metrics
No merged PRs in 30d

Description

Hi

Love the library.

How do you feel about adding the append method that is currently missing.

```php
/**
* Append attributes to query when building a query.
*
* @param array|string $attributes
* @return $this
*/
public function append($attributes)
{
$this->appends = array_unique(
array_merge($this->appends, is_string($attributes) ? func_get_args() : $attributes)
);

return $this;
}
```

This way we can append dynamically and they'll be present when the final model is requested via toArray();

```php
$model->append('thing');

$model->toArray(); // includes ["thing" => ....]
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.