4
4
5
5
use Illuminate \Bus \Queueable ;
6
6
use Illuminate \Contracts \Queue \ShouldQueue ;
7
- use Illuminate \Queue \SerializesModels ;
8
7
use Laravel \Scout \Scout ;
9
8
10
9
class MakeRangeSearchable implements ShouldQueue
11
10
{
12
- use Queueable, SerializesModels ;
11
+ use Queueable;
13
12
14
13
/**
15
14
* The model to be made searchable.
16
15
*
17
- * @var \Illuminate\Database\Eloquent\Model
16
+ * @var string
18
17
*/
19
- public $ model ;
18
+ public $ class ;
20
19
21
20
/**
22
21
* The start id to be made searchable.
@@ -35,14 +34,14 @@ class MakeRangeSearchable implements ShouldQueue
35
34
/**
36
35
* Create a new job instance.
37
36
*
38
- * @param \Illuminate\Database\Eloquent\Model $model
37
+ * @param string $class
39
38
* @param int $start
40
39
* @param int $end
41
40
* @return void
42
41
*/
43
- public function __construct ($ model , $ start , $ end )
42
+ public function __construct ($ class , $ start , $ end )
44
43
{
45
- $ this ->model = $ model ;
44
+ $ this ->class = $ class ;
46
45
$ this ->start = $ start ;
47
46
$ this ->end = $ end ;
48
47
}
@@ -54,8 +53,10 @@ public function __construct($model, $start, $end)
54
53
*/
55
54
public function handle ()
56
55
{
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 ])
59
60
->get ()
60
61
->filter
61
62
->shouldBeSearchable ();
@@ -65,7 +66,7 @@ public function handle()
65
66
}
66
67
67
68
dispatch (new Scout::$ makeSearchableJob ($ models ))
68
- ->onQueue ($ this -> model ->syncWithSearchUsingQueue ())
69
- ->onConnection ($ this -> model ->syncWithSearchUsing ());
69
+ ->onQueue ($ model ->syncWithSearchUsingQueue ())
70
+ ->onConnection ($ model ->syncWithSearchUsing ());
70
71
}
71
72
}
0 commit comments