/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //
     $movies = \App\Movie::all();
     $casts = \App\Cast::all();
     foreach ($movies as $movie) {
         foreach ($casts as $cast) {
             if (random_int(0, 1) == 1) {
                 $cm = new \App\Cast_Movie();
                 $cm->movie_id = $movie->id;
                 $cm->cast_id = $cast->id;
                 $cm->save();
             }
         }
     }
 }
示例#2
0
 function castMenu()
 {
     $data = Cast::all()->take(16);
     $theme = CastTheme::all();
     $themeAry = [];
     foreach ($theme as $name) {
         $themeAry[$name['Name']] = $name['Name'];
     }
     $wholeData = ['data' => $data, 'theme' => $themeAry];
     return view('castMenu', $wholeData);
 }