mirror of
https://github.com/crater-invoice/crater.git
synced 2025-12-15 18:02:55 -05:00
build version 400
This commit is contained in:
@@ -1,22 +1,34 @@
|
||||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
namespace Database\Factories;
|
||||
|
||||
use Crater\Payment;
|
||||
use Crater\PaymentMethod;
|
||||
use Crater\User;
|
||||
use Crater\Invoice;
|
||||
use Faker\Generator as Faker;
|
||||
use Crater\Models\Payment;
|
||||
use Crater\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
$factory->define(Payment::class, function (Faker $faker) {
|
||||
return [
|
||||
'user_id' => function () {
|
||||
return factory(User::class)->create(['role' => 'customer'])->id;
|
||||
},
|
||||
'payment_date' => $faker->date($format = 'Y-m-d', $max = 'now'),
|
||||
'company_id' => User::find(1)->company_id,
|
||||
'notes' => $faker->text(80),
|
||||
'amount' => $faker->randomDigitNotNull,
|
||||
'payment_number' => 'PAY-'.Payment::getNextPaymentNumber('PAY'),
|
||||
];
|
||||
});
|
||||
class PaymentFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Payment::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'user_id' => User::factory()->create(['role' => 'customer'])->id,
|
||||
'company_id' => User::where('role', 'super admin')->first()->company_id,
|
||||
'payment_date' => $this->faker->date('Y-m-d', 'now'),
|
||||
'notes' => $this->faker->text(80),
|
||||
'amount' => $this->faker->randomDigitNotNull,
|
||||
'payment_number' => 'PAY-' . Payment::getNextPaymentNumber('PAY'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user