PHP 8.3.31
Preview: SerializesAndRestoresModelIdentifiers.php Size: 3.84 KB
/home/getspomw/royalsquad.us/vendor/laravel/framework/src/Illuminate/Queue/SerializesAndRestoresModelIdentifiers.php

<?php

namespace Illuminate\Queue;

use Illuminate\Contracts\Database\ModelIdentifier;
use Illuminate\Contracts\Queue\QueueableCollection;
use Illuminate\Contracts\Queue\QueueableEntity;
use Illuminate\Database\Eloquent\Collection as EloquentCollection;
use Illuminate\Database\Eloquent\Relations\Concerns\AsPivot;
use Illuminate\Database\Eloquent\Relations\Pivot;
use Illuminate\Support\Collection;

trait SerializesAndRestoresModelIdentifiers
{
    /**
     * Get the property value prepared for serialization.
     *
     * @param  mixed  $value
     * @param  bool  $withRelations
     * @return mixed
     */
    protected function getSerializedPropertyValue($value, $withRelations = true)
    {
        if ($value instanceof QueueableCollection) {
            return (new ModelIdentifier(
                $value->getQueueableClass(),
                $value->getQueueableIds(),
                $withRelations ? $value->getQueueableRelations() : [],
                $value->getQueueableConnection()
            ))->useCollectionClass(
                ($collectionClass = get_class($value)) !== EloquentCollection::class
                    ? $collectionClass
                    : null
            );
        }

        if ($value instanceof QueueableEntity) {
            return new ModelIdentifier(
                get_class($value),
                $value->getQueueableId(),
                $withRelations ? $value->getQueueableRelations() : [],
                $value->getQueueableConnection()
            );
        }

        return $value;
    }

    /**
     * Get the restored property value after deserialization.
     *
     * @param  mixed  $value
     * @return mixed
     */
    protected function getRestoredPropertyValue($value)
    {
        if (! $value instanceof ModelIdentifier) {
            return $value;
        }

        return is_array($value->id)
                ? $this->restoreCollection($value)
                : $this->restoreModel($value);
    }

    /**
     * Restore a queueable collection instance.
     *
     * @param  \Illuminate\Contracts\Database\ModelIdentifier  $value
     * @return \Illuminate\Database\Eloquent\Collection
     */
    protected function restoreCollection($value)
    {
        if (! $value->class || count($value->id) === 0) {
            return ! is_null($value->collectionClass ?? null)
                ? new $value->collectionClass
                : new EloquentCollection;
        }

        $collection = $this->getQueryForModelRestoration(
            (new $value->class)->setConnection($value->connection), $value->id
        )->useWritePdo()->get();

        if (is_a($value->class, Pivot::class, true) ||
            in_array(AsPivot::class, class_uses($value->class))) {
            return $collection;
        }

        $collection = $collection->keyBy->getKey();

        $collectionClass = get_class($collection);

        return new $collectionClass(
            (new Collection($value->id))
                ->map(fn ($id) => $collection[$id] ?? null)
                ->filter()
        );
    }

    /**
     * Restore the model from the model identifier instance.
     *
     * @param  \Illuminate\Contracts\Database\ModelIdentifier  $value
     * @return \Illuminate\Database\Eloquent\Model
     */
    public function restoreModel($value)
    {
        return $this->getQueryForModelRestoration(
            (new $value->class)->setConnection($value->connection), $value->id
        )->useWritePdo()->firstOrFail()->load($value->relations ?? []);
    }

    /**
     * Get the query for model restoration.
     *
     * @template TModel of \Illuminate\Database\Eloquent\Model
     *
     * @param  TModel  $model
     * @param  array|int  $ids
     * @return \Illuminate\Database\Eloquent\Builder<TModel>
     */
    protected function getQueryForModelRestoration($model, $ids)
    {
        return $model->newQueryForRestoration($ids);
    }
}

Directory Contents

Dirs: 8 × Files: 26

Name Size Perms Modified Actions
- drwxrwxrwx 2025-09-17 06:52:57
Edit Download
Capsule DIR
- drwxrwxrwx 2025-09-17 06:52:57
Edit Download
- drwxrwxrwx 2025-09-17 06:52:57
Edit Download
Console DIR
- drwxrwxrwx 2025-09-17 06:52:57
Edit Download
Events DIR
- drwxrwxrwx 2025-09-17 06:52:57
Edit Download
Failed DIR
- drwxrwxrwx 2025-09-17 06:52:57
Edit Download
Jobs DIR
- drwxrwxrwx 2025-09-17 06:52:57
Edit Download
- drwxrwxrwx 2025-09-17 06:52:57
Edit Download
5.92 KB lrw-rw-rw- 2025-09-17 06:52:57
Edit Download
2.50 KB lrw-rw-rw- 2025-09-17 06:52:57
Edit Download
9.25 KB lrw-rw-rw- 2025-09-17 06:52:57
Edit Download
1.79 KB lrw-rw-rw- 2025-09-17 06:52:57
Edit Download
11.60 KB lrw-rw-rw- 2025-09-17 06:52:57
Edit Download
6.90 KB lrw-rw-rw- 2025-09-17 06:52:56
Edit Download
552 B lrw-rw-rw- 2025-09-17 06:52:56
Edit Download
1.05 KB lrw-rw-rw- 2025-09-17 06:52:56
Edit Download
5.62 KB lrw-rw-rw- 2025-09-17 06:52:57
Edit Download
902 B lrw-rw-rw- 2025-09-17 06:52:57
Edit Download
4.34 KB lrw-rw-rw- 2025-09-17 06:52:57
Edit Download
125 B lrw-rw-rw- 2025-09-17 06:52:57
Edit Download
587 B lrw-rw-rw- 2025-09-17 06:52:57
Edit Download
1.39 KB lrw-rw-rw- 2025-09-17 06:52:57
Edit Download
12.11 KB lrw-rw-rw- 2025-09-17 06:52:57
Edit Download
6.86 KB lrw-rw-rw- 2025-09-17 06:52:56
Edit Download
9.91 KB lrw-rw-rw- 2025-09-17 06:52:57
Edit Download
1.19 KB lrw-rw-rw- 2025-09-17 06:52:57
Edit Download
10.17 KB lrw-rw-rw- 2025-09-17 06:52:57
Edit Download
3.84 KB lrw-rw-rw- 2025-09-17 06:52:57
Edit Download
2.65 KB lrw-rw-rw- 2025-09-17 06:52:56
Edit Download
5.97 KB lrw-rw-rw- 2025-09-17 06:52:57
Edit Download
4.72 KB lrw-rw-rw- 2025-09-17 06:52:57
Edit Download
437 B lrw-rw-rw- 2025-09-17 06:52:57
Edit Download
25.79 KB lrw-rw-rw- 2025-09-17 06:52:57
Edit Download
2.43 KB lrw-rw-rw- 2025-09-17 06:52:57
Edit Download

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