@@ -33,16 +33,6 @@ class GenerateImageMove extends Command
33
33
*/
34
34
protected $ description = 'Move local images to s3 ' ;
35
35
36
- /**
37
- * Create a new command instance.
38
- *
39
- * @return void
40
- */
41
- public function __construct ()
42
- {
43
- parent ::__construct ();
44
- }
45
-
46
36
/**
47
37
* Execute the console command.
48
38
*
@@ -51,79 +41,81 @@ public function __construct()
51
41
public function handle ()
52
42
{
53
43
$ count = 0 ;
44
+ $ imageField = 'image ' ;
45
+ $ thumbName = '_thumb ' ;
54
46
55
- foreach (Calendar::whereNotNull (' image ' )->get () as $ model ) {
47
+ foreach (Calendar::whereNotNull ($ imageField )->get () as $ model ) {
56
48
$ count ++;
57
49
$ this ->move ($ model ->image );
58
- $ thumb = str_replace ('. ' , ' _thumb. ' , $ model ->image );
50
+ $ thumb = str_replace ('. ' , $ thumbName , $ model ->image );
59
51
$ this ->move ($ thumb );
60
52
}
61
- foreach (Campaign::whereNotNull (' image ' )->get () as $ model ) {
53
+ foreach (Campaign::whereNotNull ($ imageField )->get () as $ model ) {
62
54
$ count ++;
63
55
$ this ->move ($ model ->image );
64
- $ thumb = str_replace ('. ' , ' _thumb. ' , $ model ->image );
56
+ $ thumb = str_replace ('. ' , $ thumbName , $ model ->image );
65
57
$ this ->move ($ thumb );
66
58
}
67
- foreach (Character::whereNotNull (' image ' )->get () as $ model ) {
59
+ foreach (Character::whereNotNull ($ imageField )->get () as $ model ) {
68
60
$ count ++;
69
61
$ this ->move ($ model ->image );
70
- $ thumb = str_replace ('. ' , ' _thumb. ' , $ model ->image );
62
+ $ thumb = str_replace ('. ' , $ thumbName , $ model ->image );
71
63
$ this ->move ($ thumb );
72
64
}
73
- foreach (Event::whereNotNull (' image ' )->get () as $ model ) {
65
+ foreach (Event::whereNotNull ($ imageField )->get () as $ model ) {
74
66
$ count ++;
75
67
$ this ->move ($ model ->image );
76
- $ thumb = str_replace ('. ' , ' _thumb. ' , $ model ->image );
68
+ $ thumb = str_replace ('. ' , $ thumbName , $ model ->image );
77
69
$ this ->move ($ thumb );
78
70
}
79
- foreach (Family::whereNotNull (' image ' )->get () as $ model ) {
71
+ foreach (Family::whereNotNull ($ imageField )->get () as $ model ) {
80
72
$ count ++;
81
73
$ this ->move ($ model ->image );
82
- $ thumb = str_replace ('. ' , ' _thumb. ' , $ model ->image );
74
+ $ thumb = str_replace ('. ' , $ thumbName , $ model ->image );
83
75
$ this ->move ($ thumb );
84
76
}
85
- foreach (Item::whereNotNull (' image ' )->get () as $ model ) {
77
+ foreach (Item::whereNotNull ($ imageField )->get () as $ model ) {
86
78
$ count ++;
87
79
$ this ->move ($ model ->image );
88
- $ thumb = str_replace ('. ' , ' _thumb. ' , $ model ->image );
80
+ $ thumb = str_replace ('. ' , $ thumbName , $ model ->image );
89
81
$ this ->move ($ thumb );
90
82
}
91
- foreach (Journal::whereNotNull (' image ' )->get () as $ model ) {
83
+ foreach (Journal::whereNotNull ($ imageField )->get () as $ model ) {
92
84
$ count ++;
93
85
$ this ->move ($ model ->image );
94
- $ thumb = str_replace ('. ' , ' _thumb. ' , $ model ->image );
86
+ $ thumb = str_replace ('. ' , $ thumbName , $ model ->image );
95
87
$ this ->move ($ thumb );
96
88
}
97
- foreach (Location::whereNotNull (' image ' )->get () as $ model ) {
89
+ foreach (Location::whereNotNull ($ imageField )->get () as $ model ) {
98
90
$ count ++;
99
91
$ this ->move ($ model ->image );
100
92
$ this ->move ($ model ->map );
101
93
102
- $ thumb = str_replace ('. ' , ' _thumb. ' , $ model ->image );
94
+ $ thumb = str_replace ('. ' , $ thumbName , $ model ->image );
103
95
$ this ->move ($ thumb );
104
96
}
105
- foreach (Note::whereNotNull (' image ' )->get () as $ model ) {
97
+ foreach (Note::whereNotNull ($ imageField )->get () as $ model ) {
106
98
$ count ++;
107
99
$ this ->move ($ model ->image );
108
- $ thumb = str_replace ('. ' , ' _thumb. ' , $ model ->image );
100
+ $ thumb = str_replace ('. ' , $ thumbName , $ model ->image );
109
101
$ this ->move ($ thumb );
110
102
}
111
- foreach (Organisation::whereNotNull (' image ' )->get () as $ model ) {
103
+ foreach (Organisation::whereNotNull ($ imageField )->get () as $ model ) {
112
104
$ count ++;
113
105
$ this ->move ($ model ->image );
114
- $ thumb = str_replace ('. ' , ' _thumb. ' , $ model ->image );
106
+ $ thumb = str_replace ('. ' , $ thumbName , $ model ->image );
115
107
$ this ->move ($ thumb );
116
108
}
117
- foreach (Quest::whereNotNull (' image ' )->get () as $ model ) {
109
+ foreach (Quest::whereNotNull ($ imageField )->get () as $ model ) {
118
110
$ count ++;
119
111
$ this ->move ($ model ->image );
120
- $ thumb = str_replace ('. ' , ' _thumb. ' , $ model ->image );
112
+ $ thumb = str_replace ('. ' , $ thumbName , $ model ->image );
121
113
$ this ->move ($ thumb );
122
114
}
123
- foreach (Tag::whereNotNull (' image ' )->get () as $ model ) {
115
+ foreach (Tag::whereNotNull ($ imageField )->get () as $ model ) {
124
116
$ count ++;
125
117
$ this ->move ($ model ->image );
126
- $ thumb = str_replace ('. ' , ' _thumb. ' , $ model ->image );
118
+ $ thumb = str_replace ('. ' , $ thumbName , $ model ->image );
127
119
$ this ->move ($ thumb );
128
120
}
129
121
@@ -137,9 +129,10 @@ public function handle()
137
129
*/
138
130
protected function move ($ file )
139
131
{
140
- if (Storage::disk ('public ' )->exists ($ file )) {
141
- $ content = Storage::disk ('public ' )->get ($ file );
142
- Storage::disk ('s3 ' )->put ($ file , $ content , 'public ' );
132
+ $ disk = 'public ' ;
133
+ if (Storage::disk ($ disk )->exists ($ file )) {
134
+ $ content = Storage::disk ($ disk )->get ($ file );
135
+ Storage::disk ('s3 ' )->put ($ file , $ content , $ disk );
143
136
unset($ content );
144
137
}
145
138
}
0 commit comments