-
-
Notifications
You must be signed in to change notification settings - Fork 133
Description
Problem
Given the following action:
class SendTeamReportEmail
{
use AsAction;
public function handle(Team $team, bool $fullReport): void
{
// ...
}
}
When I'm trying to e.g. dispatch a job via SendTeamReportEmail::dispatch()
I don't get method signature.
Therefore I wrote a package which analyzes all actions in a project and creates an ide-helper file like https://github.com/barryvdh/laravel-ide-helper.
Installation
composer require --dev wulfheart/laravel-actions-ide-helper
Usage
php artisan ide-helper:actions
Result
Limitations
It is just a prototype. Therefore the package currently has some limitations.
Ignoring the decorator functions
class SendTeamReportEmail
{
use AsAction;
public function handle(Team $team, bool $fullReport): void
{
// Prepare report and send it to all $team->users.
}
public function asJob(Team $team): void
{
$this->handle($team, true);
}
}
If I understand the inner workings of Laravel Actions correctly this action has now some other parameters applied if it is dispatched as Job. Currently it assumes the parameters of the handle
function. I will have to fix this.
No default value
If a parameter has default value (e.g. bool $fullReport = true
) the default value doesn't get recognized. This will get fixed later.
Opinion
@lorisleiva What is your opinion on this? Do you think this could be an addition to Laravel Actions or a separate package to improve the developer experience?