/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::create();
     //a real lesson id
     //a real tag id
     $lessonIds = Lesson::get()->lists('id')->all();
     //returns an array of all lesson ids
     $tagIds = Tags::get()->lists('id')->all();
     //returns an array of all tag ids
     foreach (range(1, 30) as $index) {
         //use query builder
         DB::table('lessons_tags')->insert(['lessons_id' => $faker->randomElement($lessonIds), 'tags_id' => $faker->randomElement($tagIds)]);
     }
 }
예제 #2
0
 public function getLessonAdminIndex()
 {
     $lessons = Lesson::get();
     for ($i = 0; $i < count($lessons); $i++) {
         if ($i % 3 == 0) {
             $lessons[$i]->newRow = True;
         } else {
             $lessons[$i]->newRow = False;
         }
         if ($i % 3 == 2) {
             $lessons[$i]->endRow = True;
         } else {
             $lessons[$i]->endRow = False;
         }
         if ($i % 2 == 0) {
             $lessons[$i]->grey = "features-box-gray";
         } else {
             $lessons[$i]->grey = "";
         }
     }
     return view('lesson.adminIndex', compact('lessons'));
 }