Browse Source
Add morph relation of partner to Payment model
Add morph relation of partner to Payment model
Add partner_type on payments table Set grouped partner list on payment entry form Payment can have User model as partner Payment can have Vendor model as partner Payment can have Customer model as partnerpull/1/head
7 changed files with 90 additions and 22 deletions
-
7app/Entities/BaseRepository.php
-
2app/Entities/Payments/Payment.php
-
7app/Entities/Payments/PaymentsRepository.php
-
41database/factories/PaymentFactory.php
-
1database/migrations/2016_11_15_151228_create_payments_table.php
-
25tests/Feature/Payments/ManagePaymentsTest.php
-
29tests/Unit/Models/PaymentTest.php
@ -1,23 +1,50 @@ |
|||
<?php |
|||
|
|||
use App\Entities\Partners\Customer; |
|||
use App\Entities\Partners\Vendor; |
|||
use App\Entities\Payments\Payment; |
|||
use App\Entities\Projects\Project; |
|||
use App\Entities\Users\User; |
|||
use Faker\Generator as Faker; |
|||
|
|||
$factory->define(Payment::class, function (Faker $faker) { |
|||
|
|||
return [ |
|||
'project_id' => function () { |
|||
'project_id' => function () { |
|||
return factory(Project::class)->create()->id; |
|||
}, |
|||
'amount' => 10000, |
|||
'in_out' => 1, |
|||
'type_id' => rand(1, 3), |
|||
'date' => $faker->dateTimeBetween('-1 year', '-1 month')->format('Y-m-d'), |
|||
'description' => $faker->paragraph, |
|||
'partner_id' => function () { |
|||
'amount' => 10000, |
|||
'in_out' => 1, |
|||
'type_id' => rand(1, 3), |
|||
'date' => $faker->dateTimeBetween('-1 year', '-1 month')->format('Y-m-d'), |
|||
'description' => $faker->paragraph, |
|||
'partner_type' => Customer::class, |
|||
'partner_id' => function () { |
|||
return factory(Customer::class)->create()->id; |
|||
}, |
|||
]; |
|||
}); |
|||
|
|||
$factory->state(Payment::class, 'vendor', function (Faker $faker) { |
|||
|
|||
return [ |
|||
'in_out' => 1, |
|||
'type_id' => 1, |
|||
'partner_type' => Vendor::class, |
|||
'partner_id' => function () { |
|||
return factory(Vendor::class)->create()->id; |
|||
}, |
|||
]; |
|||
}); |
|||
|
|||
$factory->state(Payment::class, 'fee', function (Faker $faker) { |
|||
|
|||
return [ |
|||
'in_out' => 1, |
|||
'type_id' => 1, |
|||
'partner_type' => User::class, |
|||
'partner_id' => function () { |
|||
return factory(User::class)->create()->id; |
|||
}, |
|||
]; |
|||
}); |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue