Compare commits

..

3 Commits
1.3 ... main

Author SHA1 Message Date
Maxime f8804fc651 fix keys 2024-12-01 16:03:43 +01:00
Maxime 6edb16ccbf add form json 2024-11-29 16:57:06 +01:00
Maxime 52cbb95648 add form json 2024-11-29 16:12:33 +01:00
4 changed files with 10 additions and 8 deletions

View File

@ -26,13 +26,13 @@ class MakeAction extends Command
*/ */
public function handle() public function handle()
{ {
$name = $this->hasArgument('name') $name = ! empty($this->argument('name'))
? $this->argument('name') ? $this->argument('name')
: $this->ask('What is the name of the action?', 'MakeSmoothie'); : $this->ask('What is the name of the action?', 'MakeSmoothie');
$contents = file_get_contents(__DIR__.'/../stubs/action.php'); $contents = file_get_contents(__DIR__.'/../stubs/action.php');
$contents = str_replace('MakeSmoothie', $name, $contents); $contents = str_replace('MakeSmoothie', $name, $contents);
$contents = str_replace('make-smoothie', Str::slug($name), $contents); $contents = str_replace('make-smoothie', Str::snake($name, '-'), $contents);
$path = app_path('Pilot/Actions/'.$name.'.php'); $path = app_path('Pilot/Actions/'.$name.'.php');
if (file_exists($path)) { if (file_exists($path)) {

View File

@ -26,13 +26,13 @@ class MakeMetric extends Command
*/ */
public function handle() public function handle()
{ {
$name = $this->hasArgument('name') $name = ! empty($this->argument('name'))
? $this->argument('name') ? $this->argument('name')
: $this->ask('What is the name of the metric?', 'SmoothiesCount'); : $this->ask('What is the name of the metric?', 'SmoothiesCount');
$contents = file_get_contents(__DIR__.'/../stubs/metric.php'); $contents = file_get_contents(__DIR__.'/../stubs/metric.php');
$contents = str_replace('SmoothiesCount', $name, $contents); $contents = str_replace('SmoothiesCount', $name, $contents);
$contents = str_replace('smoothies-count', Str::slug($name), $contents); $contents = str_replace('smoothies-count', Str::snake($name, '-'), $contents);
$path = app_path('Pilot/Metrics/'.$name.'.php'); $path = app_path('Pilot/Metrics/'.$name.'.php');
if (file_exists($path)) { if (file_exists($path)) {

View File

@ -85,7 +85,7 @@ class PilotServiceProvider extends ServiceProvider
abort(403); abort(403);
} }
$output = $this->pilot->handle($request->all(), $request->files->all()); $output = $this->pilot->handle($request->all(), $request->allFiles());
if (isset($output['json'])) { if (isset($output['json'])) {
return response()->json($output['json']); return response()->json($output['json']);

View File

@ -29,7 +29,9 @@ class Pilot
{ {
$this->register('form', $slug, function () use ($function) { $this->register('form', $slug, function () use ($function) {
return [ return [
'json' => $function(), 'json' => [
'form' => $function()
],
]; ];
}); });
} }
@ -51,8 +53,8 @@ class Pilot
public function handle($data = [], $files = []) public function handle($data = [], $files = [])
{ {
$type = $data['type'] ?? null; $type = $data['_type'] ?? null;
$slug = $data['slug'] ?? null; $slug = $data['_slug'] ?? null;
if (isset($this->registry[$type]) && isset($this->registry[$type][$slug])) { if (isset($this->registry[$type]) && isset($this->registry[$type][$slug])) {
$params = $this->resolveDependencies($slug, $this->registry[$type][$slug], $data, $files); $params = $this->resolveDependencies($slug, $this->registry[$type][$slug], $data, $files);