Bulletinboard/database/factories/PostFactory.php

41 lines
997 B
PHP
Raw Permalink Normal View History

2021-02-24 09:01:35 +00:00
<?php
namespace Database\Factories;
use App\Models\Occupation;
use App\Models\Post;
use App\Models\Status;
use App\Models\TimePeriod;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
class PostFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Post::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
"title" => $this->faker->text(50),
"text" => $this->faker->text,
"post_time" => $this->faker->dateTime,
"time" => $this->faker->numberBetween(1,12),
"time_period_id" => TimePeriod::all()->random(1)[0]["id"],
"occupation_id" => Occupation::all()->random(1)[0]["id"],
"status_id" => Status::all()->random(1)[0]["id"],
"user_id" => User::all()->random(1)[0]["id"]
];
}
}