mirror of
				https://github.com/crater-invoice/crater.git
				synced 2025-10-31 05:31:10 -04:00 
			
		
		
		
	init crater
This commit is contained in:
		
							
								
								
									
										45
									
								
								database/factories/EstimateFactory.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								database/factories/EstimateFactory.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,45 @@ | ||||
| <?php | ||||
|  | ||||
| /** @var \Illuminate\Database\Eloquent\Factory $factory */ | ||||
|  | ||||
| use Laraspace\Estimate; | ||||
| use Laraspace\User; | ||||
| use Laraspace\Tax; | ||||
| use Faker\Generator as Faker; | ||||
| use Laraspace\EstimateItem; | ||||
| use Laraspace\EstimateTemplate; | ||||
|  | ||||
| $factory->define(Estimate::class, function (Faker $faker) { | ||||
|     return [ | ||||
|         'estimate_date' => $faker->date($format = 'd/m/Y', $max = 'now'), | ||||
|         'expiry_date' => $faker->date($format = 'd/m/Y', $max = 'now'), | ||||
|         'estimate_number' => 'EST-'.Estimate::getNextEstimateNumber(), | ||||
|         'reference_number' => Estimate::getNextEstimateNumber(), | ||||
|         'company_id' => User::find(1)->company_id, | ||||
|         'user_id' => function () { | ||||
|             return factory(User::class)->create(['role' => 'customer'])->id; | ||||
|         }, | ||||
|         'status' => Estimate::STATUS_DRAFT, | ||||
|         'estimate_template_id' => 1, | ||||
|         'sub_total' => $faker->randomDigitNotNull, | ||||
|         'discount' => 0, | ||||
|         'discount_type' => 'fixed', | ||||
|         'discount_val' => 0, | ||||
|         'tax_per_item' => 'YES', | ||||
|         'discount_per_item' => 'No', | ||||
|         'total' => $faker->randomDigitNotNull, | ||||
|         'tax' => $faker->randomDigitNotNull, | ||||
|         'notes' => $faker->text(80), | ||||
|         'unique_hash' => str_random(60) | ||||
|     ]; | ||||
| }); | ||||
|  | ||||
| $factory->afterCreating(Estimate::class, function ($estimate, $faker) { | ||||
|     $estimate->items()->save(factory(EstimateItem::class)->make()); | ||||
|     $estimate->items()->save(factory(EstimateItem::class)->make()); | ||||
| }); | ||||
|  | ||||
| $factory->afterCreating(Estimate::class, function ($estimate, $faker) { | ||||
|     $estimate->taxes()->save(factory(Tax::class)->make()); | ||||
|     $estimate->items()->save(factory(Tax::class)->make()); | ||||
| }); | ||||
		Reference in New Issue
	
	Block a user