Question: First I create a variable $formsessions in which I store a Query Builder Object (which contains 50 Formsession objects).

```
$formsessions = FormsessionsRepository::get($user, $params);

```

After this I run a groupBy() and pluck() on $formsessions which returns 3 statuses, which I store in the $formsession\_statuses variable.

```
$formsession_statuses = $formsessions->groupBy('status')->pluck('status');

```

The problem is that the $formsessions variable also get's modified after the groupBy() and pluck() and returns 3 items instead of 50. Is there a way to pluck the items from a Query Builder Object and store them in another variable without modifying the original?

Answer: 
Short answer

```
$formsessionsClone = clone $formsessions;
$formsession_statuses = $formsessionsClone->groupBy('status')->pluck('status');

```

For get unique statuses use this

```
$formsession_statuses = $formsessions->unique('status')->pluck('status');

```
By using `groupBy()` and `pluck()` will modify the variable `$formsessions`. If you don't want so then must define another variable from `$formsessions` and apply `groupBy()` and `pluck()` operations on that new variable.

```
$formsessions = FormsessionsRepository::get($user, $params);

$formsessionsNew = clone $formsessions;

$formsession_statuses = $formsessionsNew->groupBy('status')->pluck('status');

```

Read more about [clone](http://php.net/manual/en/language.oop5.cloning.php)