| 
									
										
										
										
											2018-08-03 08:14:23 +02:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // This is executed inside DatabaseMigrationService class/context
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-03 17:46:47 +02:00
										 |  |  | use Grocy\Services\LocalizationService; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-01 23:47:47 +07:00
										 |  |  | $localizationService = $this->getLocalizationService(); | 
					
						
							| 
									
										
										
										
											2018-08-03 08:14:23 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-01 23:47:47 +07:00
										 |  |  | $db = $this->getDatabaseService()->GetDbConnection(); | 
					
						
							| 
									
										
										
										
											2018-08-03 08:14:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | if ($db->quantity_units()->count() === 0) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	// Create 2 default quantity units
 | 
					
						
							| 
									
										
										
										
											2021-07-03 17:46:47 +02:00
										 |  |  | 	$newRow = $db->quantity_units()->createRow([ | 
					
						
							| 
									
										
										
										
											2019-05-02 20:20:18 +02:00
										 |  |  | 		'name' => $localizationService->__n(1, 'Piece', 'Pieces'), | 
					
						
							|  |  |  | 		'name_plural' => $localizationService->__n(2, 'Piece', 'Pieces') | 
					
						
							| 
									
										
										
										
											2021-07-03 17:46:47 +02:00
										 |  |  | 	]); | 
					
						
							| 
									
										
										
										
											2018-08-03 08:14:23 +02:00
										 |  |  | 	$newRow->save(); | 
					
						
							| 
									
										
										
										
											2021-07-03 17:46:47 +02:00
										 |  |  | 	$newRow = $db->quantity_units()->createRow([ | 
					
						
							| 
									
										
										
										
											2019-05-02 20:20:18 +02:00
										 |  |  | 		'name' => $localizationService->__n(1, 'Pack', 'Packs'), | 
					
						
							|  |  |  | 		'name_plural' => $localizationService->__n(2, 'Pack', 'Packs') | 
					
						
							| 
									
										
										
										
											2021-07-03 17:46:47 +02:00
										 |  |  | 	]); | 
					
						
							| 
									
										
										
										
											2018-08-03 08:14:23 +02:00
										 |  |  | 	$newRow->save(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if ($db->locations()->count() === 0) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	// Create a default location
 | 
					
						
							| 
									
										
										
										
											2021-07-03 17:46:47 +02:00
										 |  |  | 	$newRow = $db->locations()->createRow([ | 
					
						
							| 
									
										
										
										
											2019-05-02 20:20:18 +02:00
										 |  |  | 		'name' => $localizationService->__t('Fridge') | 
					
						
							| 
									
										
										
										
											2021-07-03 17:46:47 +02:00
										 |  |  | 	]); | 
					
						
							| 
									
										
										
										
											2018-08-03 08:14:23 +02:00
										 |  |  | 	$newRow->save(); | 
					
						
							|  |  |  | } |