/** * */ public function run() { $categories = $this->category->all(); foreach ($this->posts as $post) { $post['content'] = "Never in all their history have men been able truly to conceive of the world as one: a single sphere, a globe, having the qualities of a globe, a round earth in which all the directions eventually meet, in which there is no center because every point, or none, is center — an equal earth which all men occupy as equals. The airman's earth, if free men make it, will be truly round: a globe in practice, not in theory."; $post['slug'] = Str::slug($post['title']); $post['user_id'] = 1; $post['categories'] = [$categories[mt_rand(0, count($categories) - 1)]['id']]; $this->post->create(1, $post); } }
/** * */ public function run() { $posts = $this->post->all(); $names = ['Gigi', 'Ion', 'Boss', 'Hater']; foreach ($posts as $post) { foreach ($this->comments as $comment) { $comment = $this->comment->create(['name' => $names[array_rand($names)], 'content' => $comment, 'post_id' => $post['id']]); $replies = mt_rand(0, count($this->comments)); for ($i = 0; $i < $replies; $i++) { $this->comment->create(['name' => $names[array_rand($names)], 'content' => $this->comments[$i], 'parent_id' => $comment['id'], 'post_id' => $comment['post_id']]); } } } }
public function run() { foreach ($this->categories as $category) { $this->category->create($category); } }
/** * Find post by slug * * @param $slug * @return mixed */ public function findBySlug($slug) { return $this->category->findBySlug($slug); }