2017-06-12 17:39:03 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use App\Models\Actionlog;
|
|
|
|
|
|
|
|
$factory->defineAs(App\Models\Actionlog::class, 'asset-upload', function ($faker) {
|
|
|
|
$asset = factory(App\Models\Asset::class)->create();
|
|
|
|
return [
|
|
|
|
'item_type' => get_class($asset),
|
|
|
|
'item_id' => $asset->id,
|
|
|
|
'user_id' => function () {
|
|
|
|
return factory(App\Models\User::class)->create()->id;
|
|
|
|
},
|
|
|
|
'filename' => $faker->word,
|
|
|
|
'action_type' => 'uploaded'
|
|
|
|
];
|
|
|
|
});
|
|
|
|
|
|
|
|
$factory->defineAs(Actionlog::class, 'asset-checkout', function (Faker\Generator $faker) {
|
|
|
|
$company = factory(App\Models\Company::class)->create();
|
|
|
|
$user = factory(App\Models\User::class)->create(['company_id' => $company->id]);
|
|
|
|
$target = factory(App\Models\User::class)->create(['company_id' => $company->id]);
|
2017-10-01 12:59:55 -07:00
|
|
|
do {
|
|
|
|
$item = factory(App\Models\Asset::class)->create(['company_id' => $company->id]);
|
|
|
|
} while (!$item->isValid());
|
2017-08-31 11:14:21 -07:00
|
|
|
// dd($item);
|
2017-06-12 17:39:03 -07:00
|
|
|
return [
|
|
|
|
'user_id' => $user->id,
|
|
|
|
'action_type' => 'checkout',
|
2017-10-01 12:59:55 -07:00
|
|
|
'item_id' => $item->id,
|
2017-06-12 17:39:03 -07:00
|
|
|
'item_type' => App\Models\Asset::class,
|
|
|
|
'target_id' => $target->id,
|
|
|
|
'target_type' => get_class($target),
|
|
|
|
'created_at' => $faker->dateTime(),
|
|
|
|
'note' => $faker->sentence,
|
|
|
|
'company_id' => $company->id
|
|
|
|
];
|
|
|
|
});
|
|
|
|
|
|
|
|
$factory->defineAs(Actionlog::class, 'license-checkout-asset', function (Faker\Generator $faker) {
|
|
|
|
$company = factory(App\Models\Company::class)->create();
|
|
|
|
$user = factory(App\Models\User::class)->create(['company_id' => $company->id]);
|
|
|
|
$target = factory(App\Models\Asset::class)->create(['company_id' => $company->id]);
|
|
|
|
$item = factory(App\Models\License::class)->create(['company_id' => $company->id]);
|
|
|
|
|
|
|
|
return [
|
|
|
|
'user_id' => $user->id,
|
|
|
|
'action_type' => 'checkout',
|
|
|
|
'item_id' => $item->id,
|
|
|
|
'item_type' => get_class($item),
|
|
|
|
'target_id' => $target->id,
|
|
|
|
'target_type' => get_class($target),
|
|
|
|
'created_at' => $faker->dateTime(),
|
|
|
|
'note' => $faker->sentence,
|
|
|
|
'company_id' => $company->id
|
|
|
|
];
|
|
|
|
});
|
|
|
|
|
|
|
|
$factory->defineAs(Actionlog::class, 'accessory-checkout', function (Faker\Generator $faker) {
|
|
|
|
$company = factory(App\Models\Company::class)->create();
|
|
|
|
$user = factory(App\Models\User::class)->create(['company_id' => $company->id]);
|
|
|
|
$target = factory(App\Models\User::class)->create(['company_id' => $company->id]);
|
|
|
|
$item = factory(App\Models\Accessory::class)->create(['company_id' => $company->id]);
|
|
|
|
|
|
|
|
return [
|
|
|
|
'user_id' => $user->id,
|
|
|
|
'action_type' => 'checkout',
|
|
|
|
'item_id' => $item->id,
|
|
|
|
'item_type' => get_class($item),
|
|
|
|
'target_id' => $target->id,
|
|
|
|
'target_type' => get_class($target),
|
|
|
|
'created_at' => $faker->dateTime(),
|
|
|
|
'note' => $faker->sentence,
|
|
|
|
'company_id' => $company->id
|
|
|
|
];
|
|
|
|
});
|
|
|
|
|
|
|
|
$factory->defineAs(Actionlog::class, 'consumable-checkout', function (Faker\Generator $faker) {
|
|
|
|
$company = factory(App\Models\Company::class)->create();
|
|
|
|
$user = factory(App\Models\User::class)->create(['company_id' => $company->id]);
|
|
|
|
$target = factory(App\Models\User::class)->create(['company_id' => $company->id]);
|
|
|
|
$item = factory(App\Models\Consumable::class)->create(['company_id' => $company->id]);
|
|
|
|
|
|
|
|
return [
|
|
|
|
'user_id' => $user->id,
|
|
|
|
'action_type' => 'checkout',
|
|
|
|
'item_id' => $item->id,
|
|
|
|
'item_type' => get_class($item),
|
|
|
|
'target_id' => $target->id,
|
|
|
|
'target_type' => get_class($target),
|
|
|
|
'created_at' => $faker->dateTime(),
|
|
|
|
'note' => $faker->sentence,
|
|
|
|
'company_id' => $company->id
|
|
|
|
];
|
|
|
|
});
|
|
|
|
|
|
|
|
$factory->defineAs(Actionlog::class, 'component-checkout', function (Faker\Generator $faker) {
|
|
|
|
$company = factory(App\Models\Company::class)->create();
|
|
|
|
$user = factory(App\Models\User::class)->create(['company_id' => $company->id]);
|
|
|
|
$target = factory(App\Models\User::class)->create(['company_id' => $company->id]);
|
|
|
|
$item = factory(App\Models\Component::class)->create(['company_id' => $company->id]);
|
|
|
|
|
|
|
|
return [
|
|
|
|
'user_id' => $user->id,
|
|
|
|
'action_type' => 'checkout',
|
|
|
|
'item_id' => $item->id,
|
|
|
|
'item_type' => get_class($item),
|
|
|
|
'target_id' => $target->id,
|
|
|
|
'target_type' => get_class($target),
|
|
|
|
'created_at' => $faker->dateTime(),
|
|
|
|
'note' => $faker->sentence,
|
|
|
|
'company_id' => $company->id
|
|
|
|
];
|
|
|
|
});
|