Initial commit
This commit is contained in:
25
database/factories/AccountFactory.php
Normal file
25
database/factories/AccountFactory.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class AccountFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'name' => 'Personal Account',
|
||||
'limit_min' => 0,
|
||||
'limit_max' => 12000,
|
||||
'accountable_type' => 'App\Models\User',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
41
database/factories/AdminFactory.php
Normal file
41
database/factories/AdminFactory.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Admin;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class AdminFactory extends Factory
|
||||
{
|
||||
protected $model = Admin::class;
|
||||
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'name' => $this->faker->unique()->userName(),
|
||||
'full_name' => $this->faker->name(),
|
||||
'email' => $this->faker->unique()->safeEmail(),
|
||||
'email_verified_at' => now(),
|
||||
'password' => Hash::make('password'),
|
||||
'profile_photo_path' => null,
|
||||
'about' => $this->faker->paragraph(),
|
||||
'about_short' => $this->faker->sentence(),
|
||||
'motivation' => $this->faker->paragraph(),
|
||||
'website' => $this->faker->optional()->url(),
|
||||
'phone' => $this->faker->optional()->phoneNumber(),
|
||||
'phone_public' => $this->faker->boolean(),
|
||||
'lang_preference' => 'en',
|
||||
];
|
||||
}
|
||||
|
||||
public function unverified()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'email_verified_at' => null,
|
||||
];
|
||||
});
|
||||
}
|
||||
}
|
||||
29
database/factories/BankFactory.php
Normal file
29
database/factories/BankFactory.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Bank>
|
||||
*/
|
||||
class BankFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'name' => $this->faker->unique()->company(),
|
||||
'full_name' => $this->faker->company() . ' ' . $this->faker->companySuffix(),
|
||||
'email' => $this->faker->unique()->safeEmail(),
|
||||
'email_verified_at' => now(),
|
||||
'profile_photo_path' => $this->faker->imageUrl(128, 128),
|
||||
'about' => $this->faker->text(mt_rand(50, 300)),
|
||||
'password' => \Illuminate\Support\Facades\Hash::make('password'),
|
||||
];
|
||||
}
|
||||
}
|
||||
55
database/factories/ConversationFactory.php
Normal file
55
database/factories/ConversationFactory.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Namu\WireChat\Models\Conversation;
|
||||
use Namu\WireChat\Enums\ConversationType;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\Namu\WireChat\Models\Conversation>
|
||||
*/
|
||||
class ConversationFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Conversation::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'type' => ConversationType::Private,
|
||||
'disappearing_started_at' => null,
|
||||
'disappearing_duration' => null,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the conversation is a group.
|
||||
*/
|
||||
public function group(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'type' => ConversationType::Group,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the conversation has disappearing messages enabled.
|
||||
*/
|
||||
public function withDisappearing(int $duration = 86400): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'disappearing_started_at' => now(),
|
||||
'disappearing_duration' => $duration,
|
||||
]);
|
||||
}
|
||||
}
|
||||
24
database/factories/Locations/LocationFactory.php
Normal file
24
database/factories/Locations/LocationFactory.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories\Locations;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Model>
|
||||
*/
|
||||
class LocationFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
// 'name' => 'Default location',
|
||||
];
|
||||
}
|
||||
}
|
||||
25
database/factories/OrganizationFactory.php
Normal file
25
database/factories/OrganizationFactory.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class OrganizationFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'name' => $this->faker->company(),
|
||||
'email' => $this->faker->safeEmail(),
|
||||
'email_verified_at' => now(),
|
||||
'profile_photo_path' => $this->faker->imageUrl(128, 128),
|
||||
'about' => $this->faker->text(mt_rand(50, 300)),
|
||||
'motivation' => $this->faker->text(mt_rand(50, 150)),
|
||||
];
|
||||
}
|
||||
}
|
||||
23
database/factories/ProfileFactory.php
Normal file
23
database/factories/ProfileFactory.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class ProfileFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'first_name' => $this->faker->firstName(),
|
||||
'last_name' => $this->faker->lastName(),
|
||||
'date_of_birth' => $this->faker->dateTimeBetween('-70 year', '-18 year'),
|
||||
'content' => $this->faker->text(mt_rand(50, 300))
|
||||
];
|
||||
}
|
||||
}
|
||||
18
database/factories/TagFactory.php
Normal file
18
database/factories/TagFactory.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Tag;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class TagFactory extends Factory
|
||||
{
|
||||
protected $model = Tag::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => $this->faker->unique()->words(2, true),
|
||||
];
|
||||
}
|
||||
}
|
||||
37
database/factories/TransactionFactory.php
Normal file
37
database/factories/TransactionFactory.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Account;
|
||||
use App\Models\Transaction;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class TransactionFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Transaction::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
//TODO: use all fields
|
||||
$fromAccountId = Account::all()->random()->id;
|
||||
$toAccountId = Account::all()->random()->id;
|
||||
return [
|
||||
'from_account_id' => $fromAccountId,
|
||||
'to_account_id' => $toAccountId,
|
||||
// 'creator_user_id' => Account::find($fromAccountId)->accountable->id,
|
||||
'creator_user_id' => 1,
|
||||
'amount' => $this->faker->numberBetween(15, 2000),
|
||||
'description' => $this->faker->sentence(),
|
||||
];
|
||||
}
|
||||
}
|
||||
74
database/factories/UserFactory.php
Normal file
74
database/factories/UserFactory.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Team;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
use Laravel\Jetstream\Features;
|
||||
|
||||
class UserFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = User::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'name' => $this->faker->userName(),
|
||||
'full_name' => $this->faker->name(),
|
||||
'email' => $this->faker->unique()->safeEmail(),
|
||||
'email_verified_at' => now(),
|
||||
'password' => bcrypt('password'), // Default password
|
||||
'remember_token' => Str::random(10),
|
||||
'profile_photo_path' => 'app-images/profile-user-new.svg',
|
||||
'about' => $this->faker->text(mt_rand(50, 300)),
|
||||
'motivation' => $this->faker->text(mt_rand(50, 150)),
|
||||
'lang_preference' => 'en', // Default to null, can be set later
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model's email address should be unverified.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function unverified()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'email_verified_at' => null,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the user should have a personal team.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function withPersonalTeam()
|
||||
{
|
||||
if (! Features::hasTeamFeatures()) {
|
||||
return $this->state([]);
|
||||
}
|
||||
|
||||
return $this->has(
|
||||
Team::factory()
|
||||
->state(function (array $attributes, User $user) {
|
||||
return ['name' => $user->name.'\'s Team', 'user_id' => $user->id, 'personal_team' => true];
|
||||
}),
|
||||
'ownedTeams'
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user