Files
core/database/factories/ModelFactory.php

45 lines
1.4 KiB
PHP

<?php
/*
|--------------------------------------------------------------------------
| 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.
|
*/
use App\CMS\Contracts\Repositories\Content as ContentContract;
use App\Models\Content\Content;
use App\Models\User;
use Carbon\Carbon;
$factory->define(User::class, function (Faker\Generator $faker) {
$email = $faker->email;
return [
'username' => $email,
'email' => $email,
'name' => $faker->name,
'password' => bcrypt(str_random(10)),
'role' => 'admin',
];
});
$factory->define(Content::class, function (Faker\Generator $faker) {
$slug = isset($faker->slug) ? $faker->slug : $faker->slug(5);
return [
'title' => $faker->sentence(5),
'userId' => 1,
'url' => $slug,
'pageContent' => $faker->text(1500),
'metaDescription' => $faker->text,
'moduleHandler' => config('staticpages.handler'),
'language' => env('LOCALES'),
'publishedFrom' => Carbon::now(),
'status' => ContentContract::STATUS_PUBLIC
];
});