mirror of
				https://github.com/grocy/grocy.git
				synced 2025-10-31 02:36:54 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			34 lines
		
	
	
		
			883 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
		
			883 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| // This is executed inside DatabaseMigrationService class/context
 | |
| 
 | |
| use Grocy\Services\LocalizationService;
 | |
| 
 | |
| $localizationService = $this->getLocalizationService();
 | |
| 
 | |
| $db = $this->getDatabaseService()->GetDbConnection();
 | |
| 
 | |
| if ($db->quantity_units()->count() === 0)
 | |
| {
 | |
| 	// Create 2 default quantity units
 | |
| 	$newRow = $db->quantity_units()->createRow([
 | |
| 		'name' => $localizationService->__n(1, 'Piece', 'Pieces'),
 | |
| 		'name_plural' => $localizationService->__n(2, 'Piece', 'Pieces')
 | |
| 	]);
 | |
| 	$newRow->save();
 | |
| 	$newRow = $db->quantity_units()->createRow([
 | |
| 		'name' => $localizationService->__n(1, 'Pack', 'Packs'),
 | |
| 		'name_plural' => $localizationService->__n(2, 'Pack', 'Packs')
 | |
| 	]);
 | |
| 	$newRow->save();
 | |
| }
 | |
| 
 | |
| if ($db->locations()->count() === 0)
 | |
| {
 | |
| 	// Create a default location
 | |
| 	$newRow = $db->locations()->createRow([
 | |
| 		'name' => $localizationService->__t('Fridge')
 | |
| 	]);
 | |
| 	$newRow->save();
 | |
| }
 |