-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
208 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php | ||
|
||
namespace Ycs77\LaravelWizard\Test\Stubs; | ||
|
||
use Illuminate\Contracts\Cache\Repository as Cache; | ||
use Illuminate\Http\Request; | ||
use Ycs77\LaravelWizard\Step; | ||
use Ycs77\LaravelWizard\Wizard; | ||
|
||
class SetCacheToCleanUpStepStub extends Step | ||
{ | ||
/** | ||
* The step slug. | ||
* | ||
* @var string | ||
*/ | ||
protected $slug = 'set-cache-step-stub'; | ||
|
||
/** | ||
* The step show label text. | ||
* | ||
* @var string | ||
*/ | ||
protected $label = 'Set cache step stub'; | ||
|
||
/** | ||
* The cache store instance. | ||
*/ | ||
protected Cache $cache; | ||
|
||
/** | ||
* Create a new step instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct(Wizard $wizard, int $index, Cache $cache) | ||
{ | ||
parent::__construct($wizard, $index); | ||
|
||
$this->cache = $cache; | ||
} | ||
|
||
/** | ||
* Set the step model instance or the relationships instance. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @return \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Relations\Relation|null | ||
*/ | ||
public function model(Request $request) | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Save this step form data. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @param array|null $data | ||
* @param \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Relations\Relation|null $model | ||
* @return void | ||
*/ | ||
public function saveData(Request $request, $data = null, $model = null) | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Validation rules. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @return array | ||
*/ | ||
public function rules(Request $request) | ||
{ | ||
return [ | ||
// | ||
]; | ||
} | ||
|
||
/** | ||
* On step saved event. | ||
* | ||
* @return \Illuminate\Http\RedirectResponse|null | ||
*/ | ||
public function onStepSaved(Request $request) | ||
{ | ||
$this->cache->put('wizard.clean-up.cached', true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace Ycs77\LaravelWizard\Test\Stubs; | ||
|
||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\Cache; | ||
use Ycs77\LaravelWizard\Step; | ||
|
||
class WizardControllerCleanUpStub extends WizardControllerStub | ||
{ | ||
/** | ||
* The wizard steps instance. | ||
* | ||
* @var array | ||
*/ | ||
protected $steps = [ | ||
UserStepStub::class, | ||
SetCacheToCleanUpStepStub::class, | ||
PostStepStub::class, | ||
]; | ||
|
||
/** | ||
* On wizard step saved event. | ||
* | ||
* @return \Illuminate\Http\RedirectResponse|null | ||
*/ | ||
protected function wizardStepSaved(Request $request, Step $step) | ||
{ | ||
/** @var mixed $step */ | ||
if (method_exists($step, 'onStepSaved')) { | ||
return $step->onStepSaved($request); | ||
} | ||
} | ||
|
||
/** | ||
* Clean up the wizard event. | ||
* | ||
* @return void | ||
*/ | ||
protected function cleanUpWizard(Request $request) | ||
{ | ||
Cache::forget('wizard.clean-up.cached'); | ||
} | ||
} |