[wip] create main tables relation
This commit is contained in:
58
database/factories/AclGroupFactory.php
Normal file
58
database/factories/AclGroupFactory.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Group;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class AclGroupFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $model = Group::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'name' => $this->faker->unique()->randomElement([
|
||||
'personalia', 'supervisor', 'staff',
|
||||
]),
|
||||
'guard_name' => 'web',
|
||||
];
|
||||
}
|
||||
|
||||
public function personalia(): static
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'name' => 'personalia',
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
public function supervisor(): static
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'name' => 'supervisor',
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
public function staff(): static
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'name' => 'staff',
|
||||
];
|
||||
});
|
||||
}
|
||||
}
|
||||
20
database/factories/FormCutiFactory.php
Normal file
20
database/factories/FormCutiFactory.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class FormCutiFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Group;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
@@ -36,4 +37,19 @@ class UserFactory extends Factory
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
public function personalia()
|
||||
{
|
||||
return $this->has(Group::factory()->personalia()->count(1));
|
||||
}
|
||||
|
||||
public function supervisor()
|
||||
{
|
||||
return $this->has(Group::factory()->supervisor()->count(1));
|
||||
}
|
||||
|
||||
public function staff()
|
||||
{
|
||||
return $this->has(Group::factory()->staff()->count(1));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user