sifatbaho

This commit is contained in:
2026-04-05 05:31:24 +05:00
commit df3d57f503
2609 changed files with 369825 additions and 0 deletions

View File

@@ -0,0 +1,125 @@
<?php
namespace Database\Factories;
use App\Enums\OrderStatusEnum;
use App\Enums\RoleEnum;
use App\Models\AutoOrder;
use App\Models\Bonus;
use App\Models\OrderMembers;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\AutoOrder>
*/
class AutoOrderFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'number' => "AUTO-" . $this->faker->numberBetween(10001, 2002),
'customer_first_name' => $this->faker->firstName(),
'customer_last_name' => $this->faker->lastName(),
'customer_patronymic' => $this->faker->userName(),
'customer_company' => $this->faker->company(),
'customer_type' => $this->faker->randomElement([
'juridical', 'physical'
]),
'owner_first_name' => $this->faker->firstName(),
'owner_last_name' => $this->faker->lastName(),
'owner_patronymic' => $this->faker->userName(),
'owner_company' => $this->faker->company(),
'owner_type' => $this->faker->randomElement([
'juridical', 'physical'
]),
'purpose' => $this->faker->randomElement(["CREDIT", "REALIZE", "INVEST", "NOTARIAL"]),
'car_mark' => $this->faker->randomElement([
'Damas', 'Nexia', 'Nexia 2', 'Nexia 3', 'Spark', 'Cobalt', 'Malibu', 'Gentra'
]),
'car_category' => $this->faker->randomElement([
'local1', 'local2', 'local3', 'local4', 'local5', 'local6', 'import1',
'import2', 'import3', 'import4', 'import5', 'import6', 'special1', 'special2',
'special3', 'special4', 'special5', 'special6', 'special7', 'special8', 'special9'
]),
'car_subcategory' => $this->faker->randomElement([
'local1', 'local2', 'local3', 'local4', 'local5', 'local6', 'import1',
'import2', 'import3', 'import4', 'import5', 'import6', 'special1', 'special2',
'special3', 'special4', 'special5', 'special6', 'special7', 'special8', 'special9'
]),
'color' => $this->faker->colorName(),
'diller_id' => User::select('id')
->where('role', RoleEnum::APPRAISER->name)
->value('id'),
'made_date' => $this->faker->date('Y-m-d'),
'body' => Str::random(21),
'engine' => Str::random(21),
//AAF № 3004735 выдан CHILONZOR TRIB от 19.06.2021 года
'tech_passport' => "AAF № " . $this->faker->numberBetween(3004735, 3104735) . " выдан " . $this->faker->address() . " от " . $this->faker->date('Y-m-d') . " года",
'tech_given_date' => $this->faker->date('Y-m-d'),
'tech_given_whom' => $this->faker->address(),
'cost' => $this->faker->numberBetween(100000, 100000000),
'note' => $this->faker->sentence(10),
'type' => $this->faker->sentence(2),
'shassi' => $this->faker->sentence(1),
'car_number' => $this->faker->randomElement([01, 40, 50, 60, 70, 75, 95, 10, 25, 30, 90]) . " " . strtoupper(Str::random(1)) . " " . $this->faker->numberBetween(0, 999) . " " . strtoupper(Str::random(2)),
'status' => $this->faker->randomElement([
OrderStatusEnum::DRAFT->name,
OrderStatusEnum::STARTED->name,
OrderStatusEnum::FINISHED->name,
OrderStatusEnum::APPROVED->name,
OrderStatusEnum::REJECTED->name
])
];
}
public function configure(): AutoOrderFactory
{
return $this->afterCreating(function (AutoOrder $order) {
Log::debug("After creating AutoOrderModel", [$order->id, $order->status]);
if (in_array($order->status, [
OrderStatusEnum::STARTED->name,
OrderStatusEnum::FINISHED->name,
OrderStatusEnum::APPROVED->name,
OrderStatusEnum::REJECTED->name
])) {
Log::debug('Orders status is', [$order->status]);
$appraiser = User::select('id')
->where('role', RoleEnum::APPRAISER->name)
->first();
Log::debug("User is role appraiser some one", [$appraiser->id]);
OrderMembers::factory(1)
->create([
'user_id' => $appraiser->id,
'order_id' => $order->id
]);
if ($order->status == OrderStatusEnum::APPROVED->name) {
Log::debug("Giving bonus to appraiser for order", [$appraiser->id, $order->id]);
$givingBonusToOrderAppraiser = User::find($appraiser->id);
$bonusAmount = $this->faker->randomElement([10000, 15000, 20000], 1);
Log::debug("Bonus amount", [$bonusAmount]);
Bonus::factory(1)
->create([
'appraiser_id' => $appraiser->id,
'order_id' => $order->id,
'amount' => $bonusAmount
]);
$balance = $bonusAmount + $givingBonusToOrderAppraiser->balance;
$givingBonusToOrderAppraiser->update([
'balance' => $balance
]);
}
}
return $order;
});
}
}

View File

@@ -0,0 +1,25 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Bonus>
*/
class BonusFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition()
{
return [
'appraiser_id' => 1,
'order_id' => 1,
'amount' => 10000
];
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Debit>
*/
class DebitFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition()
{
return [
//
];
}
}

View File

@@ -0,0 +1,73 @@
<?php
namespace Database\Factories;
use App\Enums\OrderStatusEnum;
use App\Enums\PurposeEnum;
use App\Enums\RoleEnum;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Model>
*/
class EstateOrderFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition()
{
return [
'number' => "ESTATE-" . $this->faker->numberBetween(10001, 2002),
'customer_first_name' => $this->faker->firstName(),
'customer_last_name' => $this->faker->lastName(),
'customer_patronymic' => $this->faker->userName(),
'customer_company' => $this->faker->company(),
'customer_type' => $this->faker->randomElement([
'juridical', 'physical'
]),
'owner_first_name' => $this->faker->firstName(),
'owner_last_name' => $this->faker->lastName(),
'owner_patronymic' => $this->faker->userName(),
'owner_company' => $this->faker->company(),
'owner_type' => $this->faker->randomElement([
'juridical', 'physical'
]),
'purpose' => $this->faker->randomElement([
PurposeEnum::CREDIT->name,
PurposeEnum::REALIZE->name,
PurposeEnum::INVEST->name,
PurposeEnum::NOTARIAL->name
]),
'name_of_object' => $this->faker->company(),
'contract_date' => $this->faker->date('d-m-Y'),
'region' => $this->faker->address(),
'district' => $this->faker->address(),
'address' => $this->faker->address(),
'home' => $this->faker->address(),
'area' => $this->faker->randomElement([62, 79, 86, 105, 150, 300]),
'overall_area' => $this->faker->randomElement([62, 79, 86, 105, 150, 300]),
'usefull_area' => $this->faker->randomElement([62, 79, 86, 105, 150, 300]),
'live_area' => $this->faker->randomElement([62, 79, 86, 105, 150, 300]),
'diller_id' => User::select('id')
->where('role', RoleEnum::APPRAISER->name)
->value('id'),
//AAF № 3004735 выдан CHILONZOR TRIB от 19.06.2021 года
'tech_passport' => "AAF № " . $this->faker->numberBetween(3004735, 3104735) . " выдан " . $this->faker->address() . " от " . $this->faker->date('Y-m-d') . " года",
'tech_given_date' => $this->faker->date('d-m-Y'),
'tech_given_whom' => $this->faker->address(),
'cost' => $this->faker->numberBetween(100000, 100000000),
'note' => $this->faker->sentence(10),
'status' => $this->faker->randomElement([
OrderStatusEnum::DRAFT->name,
OrderStatusEnum::STARTED->name,
OrderStatusEnum::FINISHED->name,
OrderStatusEnum::APPROVED->name,
OrderStatusEnum::REJECTED->name
])
];
}
}

View File

@@ -0,0 +1,24 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Model>
*/
class OrderMembersFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition()
{
return [
'user_id' => 1,
'order_id' => 2
];
}
}

View File

@@ -0,0 +1,22 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Purpose>
*/
class PurposeFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition()
{
return [
];
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Certificate>
*/
class SertificateFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition()
{
return [
//
];
}
}

View File

@@ -0,0 +1,46 @@
<?php
namespace Database\Factories;
use App\Enums\RoleEnum;
use Exception;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
class UserFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array
* @throws Exception
*/
public function definition(): array
{
return [
'name' => $this->faker->userName(),
'phone' => '+9989' .'-'. $this->faker->numberBetween(0, 1) . '-' . $this->faker->numberBetween(000, 999) . '-' . $this->faker->numberBetween(00, 99) . '-' . $this->faker->numberBetween(00, 99),
'email_verified_at' => now(),
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
'remember_token' => Str::random(10),
'avatar' => '/assets/images/users/avatar-' . $this->faker->numberBetween(1, 10) . '.jpg',
'role' => $this->faker->randomElement([
"APPRAISER","DILLER","USER"]),
'status' => $this->faker->randomElement(['active', 'inactive'])
];
}
/**
* Indicate that the model's email address should be unverified.
*
* @return Factory
*/
public function unverified(): Factory
{
return $this->state(function (array $attributes) {
return [
'email_verified_at' => null,
];
});
}
}