add iframe action

This commit is contained in:
2025-07-02 18:07:13 +02:00
parent f8804fc651
commit b69480ccb3
3 changed files with 50 additions and 0 deletions

View File

@@ -2,6 +2,8 @@
namespace Bluesquare\Pilot\Entity;
use Illuminate\Support\Str;
abstract class Action extends Entity
{
public function action(
@@ -30,6 +32,23 @@ abstract class Action extends Entity
];
}
public function iframe($url, $expires = 240)
{
$key = 'pilot_action_' . Str::random(10);
$token = Str::random(40);
cache()->add($key, $token, now()->addMinutes($expires));
$url = $url . (str_contains($url, '?') ? '&' : '?') . "pilot_token=$key|$token";
return [
'json' => [
'type' => 'iframe',
'url' => $url,
],
];
}
public function error($message)
{
return [