1. Go to this page and download the library: Download defstudio/actions library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
defstudio / actions example snippets
/**
* @method static void run(Report|int $report)
*/
class DeleteReport
{
use ActsAsAction;
public function handle(Report|int $report): void
{
if (is_int($report)) {
$report = Report::findOrFail($report);
}
DB::transaction(function () use ($report) {
$report->delete_data();
$report->delete();
});
}
}
class DeleteReport extends \DefStudio\Actions\Action
{
public function handle(Report|int $report): bool
{
if (is_int($report)) {
$report = Report::findOrFail($report);
}
return DB::transaction(function () use ($report) {
$report->delete_data();
return $report->delete();
});
}
}
use DefStudio\Actions\Concerns\ActsAsJob;
class LongRunningAction{
use ActsAsJob;
public int $timeout = 2 * 60 * 60;
public int $tries = 4;
public array $backoff = [60, 120, 300, 600];
public string $queue = 'long-running';
public function handle(){...}
}
class LongRunningAction{
use ActsAsJob;
public function handle(){..}
public function jobFailed($exception)
{
$this->handleFailure();
}
private function handleFailure(){..}
}