PHP 8.3.31
Preview: Batchable.php Size: 2.76 KB
/home/getspomw/royalsquad.us/vendor/laravel/framework/src/Illuminate/Bus/Batchable.php

<?php

namespace Illuminate\Bus;

use Carbon\CarbonImmutable;
use Illuminate\Container\Container;
use Illuminate\Support\Str;
use Illuminate\Support\Testing\Fakes\BatchFake;

trait Batchable
{
    /**
     * The batch ID (if applicable).
     *
     * @var string
     */
    public $batchId;

    /**
     * The fake batch, if applicable.
     *
     * @var \Illuminate\Support\Testing\Fakes\BatchFake
     */
    private $fakeBatch;

    /**
     * Get the batch instance for the job, if applicable.
     *
     * @return \Illuminate\Bus\Batch|null
     */
    public function batch()
    {
        if ($this->fakeBatch) {
            return $this->fakeBatch;
        }

        if ($this->batchId) {
            return Container::getInstance()->make(BatchRepository::class)?->find($this->batchId);
        }
    }

    /**
     * Determine if the batch is still active and processing.
     *
     * @return bool
     */
    public function batching()
    {
        $batch = $this->batch();

        return $batch && ! $batch->cancelled();
    }

    /**
     * Set the batch ID on the job.
     *
     * @param  string  $batchId
     * @return $this
     */
    public function withBatchId(string $batchId)
    {
        $this->batchId = $batchId;

        return $this;
    }

    /**
     * Indicate that the job should use a fake batch.
     *
     * @param  string  $id
     * @param  string  $name
     * @param  int  $totalJobs
     * @param  int  $pendingJobs
     * @param  int  $failedJobs
     * @param  array  $failedJobIds
     * @param  array  $options
     * @param  \Carbon\CarbonImmutable|null  $createdAt
     * @param  \Carbon\CarbonImmutable|null  $cancelledAt
     * @param  \Carbon\CarbonImmutable|null  $finishedAt
     * @return array{0: $this, 1: \Illuminate\Support\Testing\Fakes\BatchFake}
     */
    public function withFakeBatch(string $id = '',
                                  string $name = '',
                                  int $totalJobs = 0,
                                  int $pendingJobs = 0,
                                  int $failedJobs = 0,
                                  array $failedJobIds = [],
                                  array $options = [],
                                  ?CarbonImmutable $createdAt = null,
                                  ?CarbonImmutable $cancelledAt = null,
                                  ?CarbonImmutable $finishedAt = null)
    {
        $this->fakeBatch = new BatchFake(
            empty($id) ? (string) Str::uuid() : $id,
            $name,
            $totalJobs,
            $pendingJobs,
            $failedJobs,
            $failedJobIds,
            $options,
            $createdAt ?? CarbonImmutable::now(),
            $cancelledAt,
            $finishedAt,
        );

        return [$this, $this->fakeBatch];
    }
}

Directory Contents

Dirs: 1 × Files: 16

Name Size Perms Modified Actions
Events DIR
- drwxrwxrwx 2025-09-17 06:53:02
Edit Download
12.46 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
2.76 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
1.71 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
2.26 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
3.33 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
3.72 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
998 B lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
10.79 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
7.46 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
14.94 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
1.05 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
9.29 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
318 B lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
7.72 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
1.69 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
856 B lrw-rw-rw- 2025-09-17 06:53:02
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).