You've already forked pilot-sdk
update README; add Laravel stubs; add form support
This commit is contained in:
44
src/Laravel/stubs/action.php
Normal file
44
src/Laravel/stubs/action.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Pilot\Actions;
|
||||
|
||||
use Bluesquare\Pilot\Entity\Action;
|
||||
|
||||
class MakeSmoothie extends Action
|
||||
{
|
||||
protected $slug = 'make-smoothie';
|
||||
|
||||
// Optional: you may remove this method if you don't need a form
|
||||
public function form()
|
||||
{
|
||||
return [
|
||||
'flavour' => [
|
||||
'type' => 'text',
|
||||
'label' => 'Flavour',
|
||||
'required' => true,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Available params:
|
||||
* @param $data array The form data
|
||||
* @param $files array The uploaded files
|
||||
* @param $entry mixed|null The Pilot entry ID to execute the action for
|
||||
* @param $entries array<mixed> The Pilot entries ID to execute the action for
|
||||
*/
|
||||
public function handle(array $data)
|
||||
{
|
||||
if ($data['flavour'] === 'mayonnaise') {
|
||||
return $this->error('Please choose a better flavour');
|
||||
}
|
||||
|
||||
// ...
|
||||
|
||||
return $this->action(
|
||||
type: 'info',
|
||||
title: 'Smoothie',
|
||||
message: 'Your smoothie is ready!'
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user