Files
pilot-sdk/src/Laravel/stubs/action.php

45 lines
1.0 KiB
PHP

<?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!'
);
}
}