Skip to content

Commit

Permalink
Merge pull request #23 from bayareawebpro/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
bayareawebpro committed Jun 10, 2020
2 parents d2fa72b + cc00170 commit bbab505
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ jobs:
- name: Unit Tests
run: composer test
- name: Codecov
uses: codecov/codecov-action@v1.0.5
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ should always set the `namespace` for the form session to avoid conflicts with
other parts of your application that use the session store.

* `GET` requests will load the form state and data for the saved current step or fallback to step 1.
* `POST`,`PUT`,`PATCH` etc.. will validate and process the request for any step and proceed to the next configured step.
* `POST`,`PUT`,`PATCH` etc... will validate and process the request for any step and proceed to the next configured step.
* Backwards navigation can be enabled via the `canNavigateBack` method.

```php
<?php

Expand Down Expand Up @@ -424,7 +425,7 @@ The response returned will have two properties:
```


#### Form Component:
#### Example Form Component

```vue
<script>
Expand Down Expand Up @@ -479,7 +480,7 @@ The response returned will have two properties:
</template>
```

#### Input Component
#### Example Input Component

```vue
<script>
Expand Down Expand Up @@ -515,7 +516,7 @@ The response returned will have two properties:
```


#### Select Component
#### Example Select Component

```vue
<script>
Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bayareawebpro/laravel-multistep-forms",
"description": "A Responsable MultiStep Form Builder for Laravel.",
"description": "Responsable MultiStep Form Builder for Laravel.",
"license": "MIT",
"authors": [
{
Expand All @@ -9,17 +9,17 @@
}
],
"require": {
"php": "^7.1.3",
"illuminate/support": "^6.0|^7.0",
"php": "^7.4",
"illuminate/http": "^6.0|^7.0",
"illuminate/validation": "^6.0|^7.0",
"illuminate/support": "^6.0|^7.0",
"illuminate/session": "^6.0|^7.0",
"illuminate/contracts": "^6.0|^7.0"
"illuminate/contracts": "^6.0|^7.0",
"illuminate/validation": "^6.0|^7.0"
},
"require-dev": {
"orchestra/testbench": "^5.0",
"phpunit/phpunit": "^8.0",
"nunomaduro/larastan": "^0.5"
"orchestra/testbench": "^5.0",
"nunomaduro/larastan": "^0.6"
},
"autoload": {
"psr-4": {
Expand Down
15 changes: 8 additions & 7 deletions src/MultiStepForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ public static function make(?string $view = null, array $data = []): self
*/
protected function handleRequest()
{
$this->setupSession();

if (!$this->request->isMethod('GET')) {

if ($response = (
Expand Down Expand Up @@ -109,7 +111,7 @@ protected function renderResponse()
$shouldGoBack = $this->shouldNavigateBack();

if(!$this->usesViews() || $this->needsJsonResponse()){
return new JsonResponse([
return new JsonResponse((object) [
'data' => $this->getData(),
'form' => $this->toArray(),
]);
Expand Down Expand Up @@ -182,9 +184,9 @@ public function canNavigateBack(bool $enabled = true): self

/**
* Handle Backwards Navigation.
* @return bool|int
* @return bool
*/
protected function shouldNavigateBack()
protected function shouldNavigateBack(): bool
{
if (
$this->canGoBack &&
Expand All @@ -195,7 +197,7 @@ protected function shouldNavigateBack()
if ($this->steps->has($step) && $this->isPast($step)) {
$this->setValue('form_step', $step);
}
return true;
return true; //Redirect back without query.
}
return false;
}
Expand Down Expand Up @@ -300,7 +302,6 @@ protected function setupSession(): void
public function namespaced(string $namespace): self
{
$this->namespace = $namespace;
$this->setupSession();
return $this;
}

Expand All @@ -309,7 +310,7 @@ public function namespaced(string $namespace): self
* @param Closure|mixed $closure
* @return $this
*/
public function tap($closure)
public function tap($closure): self
{
$closure($this);
return $this;
Expand Down Expand Up @@ -481,4 +482,4 @@ protected function handleAfter($key)
return $callback($this);
}
}
}
}

0 comments on commit bbab505

Please sign in to comment.