/** * Run the database seeds. * * @return void */ public function run() { $threads = Thread::all(); $users = User::all(); foreach ($threads as $thread) { factory(App\Post::class, mt_rand(1, 15))->create(['thread_id' => $thread->id, 'user_id' => $users->random()->id]); } }
/** * Display a listing of the resource. * * @return Response */ public function index() { $threads = Thread::all(); return view('Forum.ForumIndex', compact('threads')); }