File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change 3
3
namespace Statamic \Eloquent \Forms ;
4
4
5
5
use Statamic \Contracts \Forms \SubmissionQueryBuilder as BuilderContract ;
6
+ use Statamic \Data \DataCollection ;
6
7
use Statamic \Facades \Form ;
7
8
use Statamic \Query \EloquentQueryBuilder ;
8
9
use Statamic \Support \Str ;
@@ -34,7 +35,7 @@ protected function column($column)
34
35
35
36
protected function transform ($ items , $ columns = [])
36
37
{
37
- return $ items ->map (function ($ model ) {
38
+ return DataCollection:: make ( $ items) ->map (function ($ model ) {
38
39
return Submission::fromModel ($ model )
39
40
->form (Form::find ($ model ->form ));
40
41
});
Original file line number Diff line number Diff line change 5
5
use Carbon \Carbon ;
6
6
use Illuminate \Support \Facades \Event ;
7
7
use PHPUnit \Framework \Attributes \Test ;
8
+ use Statamic \Data \DataCollection ;
8
9
use Statamic \Eloquent \Forms \FormModel ;
10
+ use Statamic \Eloquent \Forms \Submission ;
9
11
use Statamic \Eloquent \Forms \SubmissionModel ;
10
12
use Statamic \Events \SubmissionCreated ;
11
13
use Statamic \Events \SubmissionDeleted ;
@@ -169,4 +171,19 @@ public function it_should_delete_quietly()
169
171
Event::assertDispatched (SubmissionDeleted::class);
170
172
$ this ->assertSame ($ result , true );
171
173
}
174
+
175
+ #[Test]
176
+ public function querying_submissions_should_return_data_collections ()
177
+ {
178
+ $ form = Facades \Form::make ('test ' );
179
+
180
+ $ form ->makeSubmission ([
181
+ 'name ' => 'John Doe ' ,
182
+ ])->save ();
183
+
184
+ $ submissions = $ form ->querySubmissions ()->get ();
185
+
186
+ $ this ->assertInstanceOf (DataCollection::class, $ submissions );
187
+ $ this ->assertEveryItemIsInstanceOf (Submission::class, $ submissions );
188
+ }
172
189
}
You can’t perform that action at this time.
0 commit comments