%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/html/news/database/factories/
Upload File :
Create Path :
Current File : /var/www/html/news/database/factories/ModelFactory.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.
|
*/

/** @var \Illuminate\Database\Eloquent\Factory $factory */
use App\Models\Article;
use App\Models\Category;
use App\Models\Comment;
use App\Models\Subscription;
use App\Models\Tag;
use App\Models\User;

$factory->define(User::class, function () {
    $faker = \Faker\Factory::create();

    return [
        'name'      => $faker->name,
        'surname'   => $faker->lastName,
        'email'     => $faker->unique()->safeEmail,
        'birthdate' => $faker->date(),
        'password'  => 'password',
        'is_active' => $faker->boolean(),
    ];
});

$factory->define(Category::class, function () {
    $faker = \Faker\Factory::create();

    return [
        'name'        => $faker->unique()->domainWord,
        'description' => $faker->sentence
    ];
});

$factory->define(Tag::class, function () {
    $faker = \Faker\Factory::create();

    return [
        'tag' => $faker->unique()->domainWord
    ];
});

$factory->define(Article::class, function () {
    $faker = \Faker\Factory::create();
    $userId = User::orderByRaw('RAND()')->first()->id;
    return [
        'title'            => $faker->title,
        'description'      => $faker->sentence,
        'content'          => $faker->paragraph,
        'creator_id'       => $userId,
        'last_modifier_id' => $userId,
        'category_id'      => Category::orderByRaw('RAND()')->first()->id
    ];
});

$factory->define(Comment::class, function () {
    $faker = \Faker\Factory::create();
    return [
        'content'     => $faker->sentence,
        'is_approved' => $faker->boolean,
        'user_id'     => User::orderByRaw('RAND()')->first()->id,
        'article_id'  => Article::orderByRaw('RAND()')->first()->id,
    ];
});

$factory->define(Subscription::class, function () {
    $faker = \Faker\Factory::create();
    return [
        'firstname' => $faker->firstName,
        'lastname'  => $faker->lastName,
        'email'     => $faker->email,
        'is_active' => $faker->boolean,
        'token'     => bcrypt(uniqid().\Carbon\Carbon::now())
    ];
});

Zerion Mini Shell 1.0