2525
2626class FromDataPack
2727{
28- private Filesystem $ uploadsDisk ;
28+ private readonly Filesystem $ uploadsDisk ;
2929
3030 /** @var array<string> */
3131 private array $ barShelf = [];
@@ -107,9 +107,9 @@ private function importBaseData(string $tableName, string $filepath, int $barId)
107107 }, $ data );
108108
109109 // Skip duplicates
110- $ existing = DB ::table ($ tableName )->select ('name ' )->where ('bar_id ' , $ barId )->get ()->keyBy (fn ($ row ) => strtolower ($ row ->name ))->toArray ();
110+ $ existing = DB ::table ($ tableName )->select ('name ' )->where ('bar_id ' , $ barId )->get ()->keyBy (fn ($ row ) => strtolower (( string ) $ row ->name ))->toArray ();
111111 $ importData = array_filter ($ importData , function ($ item ) use ($ existing ) {
112- if (array_key_exists (strtolower ($ item ['name ' ]), $ existing )) {
112+ if (array_key_exists (strtolower (( string ) $ item ['name ' ]), $ existing )) {
113113 return false ;
114114 }
115115
@@ -127,9 +127,9 @@ private function importCalculators(string $filepath, int $barId): void
127127 $ data = [];
128128 }
129129
130- $ existing = DB ::table ('calculators ' )->select ('name ' )->where ('bar_id ' , $ barId )->get ()->keyBy (fn ($ row ) => strtolower ($ row ->name ))->toArray ();
130+ $ existing = DB ::table ('calculators ' )->select ('name ' )->where ('bar_id ' , $ barId )->get ()->keyBy (fn ($ row ) => strtolower (( string ) $ row ->name ))->toArray ();
131131 $ data = array_filter ($ data , function ($ item ) use ($ existing ) {
132- if (array_key_exists (strtolower ($ item ['name ' ]), $ existing )) {
132+ if (array_key_exists (strtolower (( string ) $ item ['name ' ]), $ existing )) {
133133 return false ;
134134 }
135135
@@ -175,9 +175,7 @@ private function importIngredients(Filesystem $dataDisk, Bar $bar, User $user):
175175 {
176176 $ timerStart = microtime (true );
177177
178- $ existingIngredients = DB ::table ('ingredients ' )->select ('id ' , 'name ' )->where ('bar_id ' , $ bar ->id )->get ()->keyBy (function ($ ingredient ) {
179- return Str::slug ($ ingredient ->name );
180- });
178+ $ existingIngredients = DB ::table ('ingredients ' )->select ('id ' , 'name ' )->where ('bar_id ' , $ bar ->id )->get ()->keyBy (fn ($ ingredient ) => Str::slug ($ ingredient ->name ));
181179
182180 $ ingredientsToInsert = [];
183181 $ parentIngredientsToInsert = [];
@@ -322,9 +320,7 @@ private function importBaseCocktails(Filesystem $dataDisk, Bar $bar, User $user)
322320 $ dbIngredients = DB ::table ('ingredients ' )->select ('id ' , DB ::raw ('LOWER(name) AS name ' ))->where ('bar_id ' , $ bar ->id )->get ()->keyBy ('name ' )->map (fn ($ row ) => $ row ->id )->toArray ();
323321 $ dbGlasses = DB ::table ('glasses ' )->select ('id ' , DB ::raw ('LOWER(name) AS name ' ))->where ('bar_id ' , $ bar ->id )->get ()->keyBy ('name ' )->map (fn ($ row ) => $ row ->id )->toArray ();
324322 $ dbMethods = DB ::table ('cocktail_methods ' )->select ('id ' , DB ::raw ('LOWER(name) AS name ' ))->where ('bar_id ' , $ bar ->id )->get ()->keyBy ('name ' )->map (fn ($ row ) => $ row ->id )->toArray ();
325- $ existingCocktails = DB ::table ('cocktails ' )->select ('id ' , 'name ' )->where ('bar_id ' , $ bar ->id )->get ()->keyBy (function ($ cocktail ) {
326- return Str::slug ($ cocktail ->name );
327- });
323+ $ existingCocktails = DB ::table ('cocktails ' )->select ('id ' , 'name ' )->where ('bar_id ' , $ bar ->id )->get ()->keyBy (fn ($ cocktail ) => Str::slug ($ cocktail ->name ));
328324
329325 $ cocktailImages = [];
330326 $ uniqueTags = [];
0 commit comments