コード例 #1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     if (Article::count() > 0 && Topic::count() > 0) {
         foreach (range(1, 10) as $index) {
             DB::table('article_topic')->insert(['article_id' => rand(1, Article::count()), 'topic_id' => rand(1, Topic::count())]);
         }
     }
 }
コード例 #2
0
 public function showIndex()
 {
     // the current page number
     $page = isset($_GET['page']) ? (int) $_GET['page'] : 1;
     $perPage = 4;
     $totalCount = Topic::count();
     $pagination = new Pagination($page, $perPage, $totalCount);
     $topics = Topic::allTopics($perPage, $pagination->offset()) or redirect(404);
     echo $this->blade->render('home', compact('topics', 'pagination'));
 }