Run actions
Hiker’s runnable nodes are your bread and butter. They represent one action within your flow and simply execute the code you provide to them.
- Name your actions with a class
- Avoid duplicated logic
- Improve modularity
1public function create(): Roadmap
2{
3 return roadmap()
4 ->run(FetchWeatherConditions::class)
5 ->branch(CheckWeather::class, function (Outcome $weather) {
6 $weather->is('rainy')
7 ->show(RaincoatForm::class);
8 $weather->is('sunny')
9 ->show(ShadesForm::class);
10 })
11 ->save(SaveJourney::class)
12 ->chain('draft', Picnic::class)
13 ->show(JourneyDetail::class);
14}