@@ -66,15 +66,7 @@ public function createSubmission($data, $user, $isClaim = false, $isDraft = fals
6666 if ($ prompt ->limit ) {
6767 // check that the user hasn't hit the prompt submission limit
6868 // filter the submissions by hour/day/week/etc and count
69- $ count ['all ' ] = Submission::submitted ($ prompt ->id , $ user ->id )->count ();
70- $ count ['Hour ' ] = Submission::submitted ($ prompt ->id , $ user ->id )->where ('created_at ' , '>= ' , now ()->startOfHour ())->count ();
71- $ count ['Day ' ] = Submission::submitted ($ prompt ->id , $ user ->id )->where ('created_at ' , '>= ' , now ()->startOfDay ())->count ();
72- $ count ['Week ' ] = Submission::submitted ($ prompt ->id , $ user ->id )->where ('created_at ' , '>= ' , now ()->startOfWeek ())->count ();
73- $ count ['BiWeekly ' ] = Submission::submitted ($ prompt ->id , $ user ->id )->where ('created_at ' , '>= ' , now ()->subWeeks (2 ))->count ();
74- $ count ['Month ' ] = Submission::submitted ($ prompt ->id , $ user ->id )->where ('created_at ' , '>= ' , now ()->startOfMonth ())->count ();
75- $ count ['BiMonthly ' ] = Submission::submitted ($ prompt ->id , $ user ->id )->where ('created_at ' , '>= ' , now ()->subMonths (2 ))->count ();
76- $ count ['Quarter ' ] = Submission::submitted ($ prompt ->id , $ user ->id )->where ('created_at ' , '>= ' , now ()->subMonths (3 ))->count ();
77- $ count ['Year ' ] = Submission::submitted ($ prompt ->id , $ user ->id )->where ('created_at ' , '>= ' , now ()->startOfYear ())->count ();
69+ $ count = $ prompt ->filterCount ($ user );
7870
7971 // if limit by character is on... multiply by # of chars. otherwise, don't
8072 if ($ prompt ->limit_character ) {
@@ -173,15 +165,7 @@ public function editSubmission($submission, $data, $user, $isClaim = false, $isS
173165 if ($ prompt ->limit && !($ submission ->status == 'Draft ' && $ submission ->prompt_id && $ submission ->staff_comments )) {
174166 // check that the user hasn't hit the prompt submission limit
175167 // filter the submissions by hour/day/week/etc and count
176- $ count ['all ' ] = Submission::submitted ($ prompt ->id , $ user ->id )->count ();
177- $ count ['Hour ' ] = Submission::submitted ($ prompt ->id , $ user ->id )->where ('created_at ' , '>= ' , now ()->startOfHour ())->count ();
178- $ count ['Day ' ] = Submission::submitted ($ prompt ->id , $ user ->id )->where ('created_at ' , '>= ' , now ()->startOfDay ())->count ();
179- $ count ['Week ' ] = Submission::submitted ($ prompt ->id , $ user ->id )->where ('created_at ' , '>= ' , now ()->startOfWeek ())->count ();
180- $ count ['BiWeekly ' ] = Submission::submitted ($ prompt ->id , $ user ->id )->where ('created_at ' , '>= ' , now ()->subWeeks (2 ))->count ();
181- $ count ['Month ' ] = Submission::submitted ($ prompt ->id , $ user ->id )->where ('created_at ' , '>= ' , now ()->startOfMonth ())->count ();
182- $ count ['BiMonthly ' ] = Submission::submitted ($ prompt ->id , $ user ->id )->where ('created_at ' , '>= ' , now ()->subMonths (2 ))->count ();
183- $ count ['Quarter ' ] = Submission::submitted ($ prompt ->id , $ user ->id )->where ('created_at ' , '>= ' , now ()->subMonths (3 ))->count ();
184- $ count ['Year ' ] = Submission::submitted ($ prompt ->id , $ user ->id )->where ('created_at ' , '>= ' , now ()->startOfYear ())->count ();
168+ $ count = $ prompt ->filterCount ($ user );
185169
186170 // if limit by character is on... multiply by # of chars. otherwise, don't
187171 if ($ prompt ->limit_character ) {
0 commit comments