diff --git a/api/app/Http/Controllers/Forms/FormStatsController.php b/api/app/Http/Controllers/Forms/FormStatsController.php index ecc1bb0e..efb133ff 100644 --- a/api/app/Http/Controllers/Forms/FormStatsController.php +++ b/api/app/Http/Controllers/Forms/FormStatsController.php @@ -3,8 +3,8 @@ namespace App\Http\Controllers\Forms; use App\Http\Controllers\Controller; -use App\Models\Forms\Form; use Carbon\CarbonPeriod; +use Illuminate\Http\Request; class FormStatsController extends Controller { @@ -13,10 +13,9 @@ class FormStatsController extends Controller $this->middleware('auth'); } - public function getFormStats(string $workspaceId, string $formId) + public function getFormStats(Request $request) { - $form = Form::findOrFail($formId); - + $form = $request->form; // Added by ProForm middleware $this->authorize('view', $form); $formStats = $form->statistics()->where('date', '>', now()->subDays(29)->startOfDay())->get(); diff --git a/api/routes/api.php b/api/routes/api.php index 41b0962e..c0376e2c 100644 --- a/api/routes/api.php +++ b/api/routes/api.php @@ -144,7 +144,9 @@ Route::group(['middleware' => 'auth:api'], function () { Route::put('/custom-domains', [WorkspaceController::class, 'saveCustomDomain'])->name('save-custom-domains'); Route::delete('/', [WorkspaceController::class, 'delete'])->name('delete'); - Route::get('form-stats/{formId}', [FormStatsController::class, 'getFormStats'])->name('form.stats'); + Route::middleware('pro-form')->group(function () { + Route::get('form-stats/{formId}', [FormStatsController::class, 'getFormStats'])->name('form.stats'); + }); }); }); diff --git a/api/tests/Feature/Forms/FormStatTest.php b/api/tests/Feature/Forms/FormStatTest.php index e21bd810..9051937e 100644 --- a/api/tests/Feature/Forms/FormStatTest.php +++ b/api/tests/Feature/Forms/FormStatTest.php @@ -3,7 +3,7 @@ use Illuminate\Support\Facades\Artisan; it('check formstat chart data', function () { - $user = $this->actingAsUser(); + $user = $this->actingAsProUser(); $workspace = $this->createUserWorkspace($user); $form = $this->createForm($user, $workspace, []); diff --git a/client/components/open/forms/components/FormStats.vue b/client/components/open/forms/components/FormStats.vue index 7a5e0962..445dcbf4 100644 --- a/client/components/open/forms/components/FormStats.vue +++ b/client/components/open/forms/components/FormStats.vue @@ -3,7 +3,7 @@ class="border border-nt-blue-light bg-blue-50 dark:bg-notion-dark-light rounded-md p-4 mb-5 w-full mx-auto mt-4 select-all" >
-