Пример #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();
 }
Пример #2
0
 public function compose(View $view)
 {
     $sticky_posts = \App\Modules\ForumModule\Entities\Post::withMeta()->sticky()->orderedByDate()->get();
     $view->with('sticky_posts', $sticky_posts);
 }
Пример #3
0
 public function delete(User $user, Post $post)
 {
     return $user->is($post->getAuthor());
 }
Пример #4
0
 public function index()
 {
     $posts = Post::withMeta()->orderedByScore()->paginate(10);
     return view('forum::posts.index', compact('posts'));
 }
Пример #5
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     $this->post->increment('views');
 }