- added folder, file factories

This commit is contained in:
Peter Papp
2021-02-26 17:32:59 +01:00
parent 920ee19651
commit 1359b78d21
4 changed files with 101 additions and 5 deletions

View File

@@ -0,0 +1,52 @@
<?php
namespace Database\Factories;
use App\File;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
class FileFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = File::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'id' => $this->faker->uuid,
'user_id' => $this->faker->uuid,
'name' => $this->faker->name,
'type' => $this->faker->randomElement(
['image', 'file', 'video', 'audio']
),
'user_scope' => $this->faker->randomElement(
['master', 'editor', 'visitor']
),
'created_at' => $this->faker->dateTimeBetween(
$startDate = '-36 months', $endDate = 'now', $timezone = null
),
];
}
/**
* Configure the model factory.
*
* @return $this
*/
public function configure()
{
return $this->afterCreating(function (File $file) {
// TODO: add fake files
});
}
}

View File

@@ -0,0 +1,36 @@
<?php
namespace Database\Factories;
use App\Folder;
use Illuminate\Database\Eloquent\Factories\Factory;
class FolderFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Folder::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'id' => $this->faker->uuid,
'user_id' => $this->faker->uuid,
'name' => $this->faker->name,
'user_scope' => $this->faker->randomElement(
['master', 'editor', 'visitor']
),
'created_at' => $this->faker->dateTimeBetween(
$startDate = '-36 months', $endDate = 'now', $timezone = null
),
];
}
}

View File

@@ -25,13 +25,17 @@ class UserFactory extends Factory
public function definition()
{
return [
'role' => $this->faker->randomElement(['user', 'admin']),
'role' => $this->faker->randomElement(
['user', 'admin']
),
'name' => $this->faker->name(),
'email' => $this->faker->unique()->safeEmail,
'email_verified_at' => now(),
'password' => Hash::make('secret'),
'remember_token' => Str::random(10),
'created_at' => $this->faker->dateTimeBetween($startDate = '-36 months', $endDate = 'now', $timezone = null),
'created_at' => $this->faker->dateTimeBetween(
$startDate = '-36 months', $endDate = 'now', $timezone = null
),
];
}
@@ -52,9 +56,13 @@ class UserFactory extends Factory
'state' => $this->faker->state,
'city' => $this->faker->city,
'postal_code' => $this->faker->postcode,
'country' => $this->faker->randomElement(['SK', 'CZ', 'DE', 'FR']),
'country' => $this->faker->randomElement(
['SK', 'CZ', 'DE', 'FR']
),
'phone_number' => $this->faker->phoneNumber,
'timezone' => $this->faker->randomElement(['+1.0', '+2.0', '+3.0']),
'timezone' => $this->faker->randomElement(
['+1.0', '+2.0', '+3.0']
),
]);
});
}