Commit 65bd6e58 authored by Viral Solani's avatar Viral Solani

create seperate model factories for user , role and permission

parent 6122c375
<?php
use App\Models\Access\Permission\Permission;
use Faker\Generator;
/*
* Permissions
*/
$factory->define(Permission::class, function (Generator $faker) {
$name = $faker->word;
return [
'name' => $name,
'display_name' => $name,
'sort' => $faker->numberBetween(1, 100),
];
});
<?php
use App\Models\Access\Role\Role;
use Faker\Generator;
/*
* Roles
*/
$factory->define(Role::class, function (Generator $faker) {
return [
'name' => $faker->name,
'all' => 0,
'sort' => $faker->numberBetween(1, 100),
];
});
$factory->state(Role::class, 'admin', function () {
return [
'all' => 1,
];
});
<?php <?php
use App\Models\Access\Permission\Permission;
use App\Models\Access\Role\Role;
use App\Models\Access\User\User; use App\Models\Access\User\User;
use Faker\Generator; use Faker\Generator;
/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| Here you may define all of your model factories. Model factories give
| you a convenient way to create models for testing and seeding your
| database. Just tell the factory how a default model should look.
|
*/
$factory->define(User::class, function (Generator $faker) { $factory->define(User::class, function (Generator $faker) {
static $password; static $password;
...@@ -53,33 +40,3 @@ $factory->state(User::class, 'unconfirmed', function () { ...@@ -53,33 +40,3 @@ $factory->state(User::class, 'unconfirmed', function () {
]; ];
}); });
/*
* Roles
*/
$factory->define(Role::class, function (Generator $faker) {
return [
'name' => $faker->name,
'all' => 0,
'sort' => $faker->numberBetween(1, 100),
];
});
$factory->state(Role::class, 'admin', function () {
return [
'all' => 1,
];
});
/*
* Permissions
*/
$factory->define(Permission::class, function (Generator $faker) {
$name = $faker->word;
return [
'name' => $name,
'display_name' => $name,
'sort' => $faker->numberBetween(1, 100),
];
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment