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