Beispiel #1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $users = $this->userRepository->findAll();
     $tags = Tag::get(['id'])->pluck('id')->toArray();
     for ($i = 0; $i < 20; $i++) {
         $user = $users->random();
         $count = mt_rand(1, 2);
         $post = Post::instantiate($user, ['title' => $user->name . '的好贴'], $this->faker->randomElements($tags, $count));
         Comment::instantiate($user, $post, ['body' => $this->faker->text, 'views' => $this->faker->numberBetween(0, 1000)]);
     }
     Post::inRandomOrder()->first()->makeSticky();
 }
Beispiel #2
0
 public function compose(View $view)
 {
     $tags = Tag::all();
     $view->with('tags', $tags);
 }
Beispiel #3
0
 public function index()
 {
     $tags = Tag::paginate();
     return view('forum::tags.index', compact('tags'));
 }