Skip to content

Commit 5ac76e8

Browse files
authored
Remove SerializesModels from MakeRangeSearchable (#930)
1 parent c80f4c6 commit 5ac76e8

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

src/Console/QueueImportCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function handle()
6060
for ($start = $min; $start <= $max; $start += $chunk) {
6161
$end = min($start + $chunk - 1, $max);
6262

63-
dispatch(new MakeRangeSearchable($model, $start, $end))
63+
dispatch(new MakeRangeSearchable($class, $start, $end))
6464
->onQueue($model->syncWithSearchUsingQueue())
6565
->onConnection($model->syncWithSearchUsing());
6666

src/Jobs/MakeRangeSearchable.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,18 @@
44

55
use Illuminate\Bus\Queueable;
66
use Illuminate\Contracts\Queue\ShouldQueue;
7-
use Illuminate\Queue\SerializesModels;
87
use Laravel\Scout\Scout;
98

109
class MakeRangeSearchable implements ShouldQueue
1110
{
12-
use Queueable, SerializesModels;
11+
use Queueable;
1312

1413
/**
1514
* The model to be made searchable.
1615
*
17-
* @var \Illuminate\Database\Eloquent\Model
16+
* @var string
1817
*/
19-
public $model;
18+
public $class;
2019

2120
/**
2221
* The start id to be made searchable.
@@ -35,14 +34,14 @@ class MakeRangeSearchable implements ShouldQueue
3534
/**
3635
* Create a new job instance.
3736
*
38-
* @param \Illuminate\Database\Eloquent\Model $model
37+
* @param string $class
3938
* @param int $start
4039
* @param int $end
4140
* @return void
4241
*/
43-
public function __construct($model, $start, $end)
42+
public function __construct($class, $start, $end)
4443
{
45-
$this->model = $model;
44+
$this->class = $class;
4645
$this->start = $start;
4746
$this->end = $end;
4847
}
@@ -54,8 +53,10 @@ public function __construct($model, $start, $end)
5453
*/
5554
public function handle()
5655
{
57-
$models = $this->model::makeAllSearchableQuery()
58-
->whereBetween($this->model->getScoutKeyName(), [$this->start, $this->end])
56+
$model = new $this->class;
57+
58+
$models = $model::makeAllSearchableQuery()
59+
->whereBetween($model->getScoutKeyName(), [$this->start, $this->end])
5960
->get()
6061
->filter
6162
->shouldBeSearchable();
@@ -65,7 +66,7 @@ public function handle()
6566
}
6667

6768
dispatch(new Scout::$makeSearchableJob($models))
68-
->onQueue($this->model->syncWithSearchUsingQueue())
69-
->onConnection($this->model->syncWithSearchUsing());
69+
->onQueue($model->syncWithSearchUsingQueue())
70+
->onConnection($model->syncWithSearchUsing());
7071
}
7172
}

0 commit comments

Comments
 (0)