Skip to content

Commit

Permalink
Added support for Repository
Browse files Browse the repository at this point in the history
  • Loading branch information
lcharette committed Feb 15, 2018
1 parent 3204efe commit c983761
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Change Log

## 2.2.10
- Added support for Repository

## 2.2.9
- Fix issue when setting data that is a collection
- `formSuccess` and `confirmSuccess` events now include the request data as a second argument
Expand Down
7 changes: 4 additions & 3 deletions src/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
*/
namespace UserFrosting\Sprinkle\FormGenerator;

use Illuminate\Support\Collection;
use Illuminate\Contracts\Config\Repository;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
use Illuminate\Support\Str;
use UserFrosting\Fortress\RequestSchema\RequestSchemaInterface;

Expand Down Expand Up @@ -58,10 +59,10 @@ public function setData($data)
{
if ($data instanceof Collection || $data instanceof Model) {
$this->data = $data->toArray();
} else if (is_array($data)) {
} else if (is_array($data) || $data instanceof Repository) {
$this->data = $data;
} else {
throw new \InvalidArgumentException("Data must be an array or a Collection");
throw new \InvalidArgumentException("Data must be an array, a Collection, a Model or a Repository");
}
}

Expand Down

0 comments on commit c983761

Please sign in to comment.