コード例 #1
0
ファイル: PostSeeder.php プロジェクト: gez-studio/gez-mall
 /**
  * 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
ファイル: PostPolicy.php プロジェクト: gez-studio/gez-mall
 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');
 }