Compare commits
3 Commits
Author | SHA1 | Date |
---|---|---|
Maxime | f8804fc651 | |
Maxime | 6edb16ccbf | |
Maxime | 52cbb95648 |
|
@ -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)) {
|
||||||
|
|
|
@ -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)) {
|
||||||
|
|
|
@ -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']);
|
||||||
|
|
|
@ -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);
|
||||||
|
|
Loading…
Reference in New Issue