From c9837615b41be8e1bf2fabf017088c1596d6b84c Mon Sep 17 00:00:00 2001 From: Louis Charette Date: Wed, 14 Feb 2018 19:55:23 -0500 Subject: [PATCH] Added support for Repository --- CHANGELOG.md | 3 +++ src/Form.php | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e25557..0975d22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/Form.php b/src/Form.php index d158690..e845e3e 100644 --- a/src/Form.php +++ b/src/Form.php @@ -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; @@ -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"); } }