From bb63cc81ae6cdaf5629fa0e8186ac85e1a89b5fa Mon Sep 17 00:00:00 2001 From: Craig Paul Date: Thu, 12 Sep 2024 06:42:43 -0600 Subject: [PATCH] Allows the field generation to take advantage of the current request to allow for things like tenant identification --- src/Http/Controllers/WorkflowController.php | 9 ++++++--- src/Support/Workflow.php | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Http/Controllers/WorkflowController.php b/src/Http/Controllers/WorkflowController.php index 428740f..ed79395 100644 --- a/src/Http/Controllers/WorkflowController.php +++ b/src/Http/Controllers/WorkflowController.php @@ -7,6 +7,7 @@ use Illuminate\Contracts\Foundation\Application; use Illuminate\Contracts\Routing\ResponseFactory; use Illuminate\Http\JsonResponse; +use Illuminate\Http\Request; use SplFileInfo; class WorkflowController @@ -30,9 +31,11 @@ public function __construct( /** * Display a listing of the resource. * + * @param \Illuminate\Http\Request $request + * * @return \Illuminate\Http\JsonResponse */ - public function index(): JsonResponse + public function index(Request $request): JsonResponse { $directory = $this->app->basePath('tests/Blitz'); @@ -46,11 +49,11 @@ public function index(): JsonResponse ), ); - $workflows = array_map(function (SplFileInfo $file) { + $workflows = array_map(function (SplFileInfo $file) use ($request) { $workflow = Workflow::fromFile($file); $namespace = $workflow->className; $fields = $workflow->customizable - ? $this->app->make($namespace)->fields() + ? $this->app->make($namespace)->fields($request) : []; return [ diff --git a/src/Support/Workflow.php b/src/Support/Workflow.php index 628260b..3217bd9 100644 --- a/src/Support/Workflow.php +++ b/src/Support/Workflow.php @@ -58,7 +58,7 @@ className: str_replace( ), ), ), - customizable: self::fileContains($file, 'public function fields()'), + customizable: self::fileContains($file, 'public function fields'), name: ucfirst( strtolower( implode(' ', preg_split('/(?=\p{Lu})/u', strstr($file->getFilename(), 'Test.php', true), -1, PREG_SPLIT_NO_EMPTY)),