public function run() { $faker = Faker::create(); $lessonIds = Lesson::lists('id'); $tagIds = Tag::lists('id'); foreach (range(1, 30) as $index) { DB::table('lesson_tag')->insert(['lesson_id' => $faker->randomElement($lessonIds), 'tag_id' => $faker->randomElement($tagIds)]); } }
public function run() { $users = User::all(); $tags = Tag::lists('id'); $last = count($tags) - 1; foreach ($users as $user) { $user->tags()->attach($tags[rand(0, $last)]); } foreach ($users as $user) { $user->tags()->attach($tags[rand(0, $last)]); } foreach ($users as $user) { $user->tags()->attach($tags[rand(0, $last)]); } }
public function run() { $tutorials = Tutorial::all(); $tags = Tag::lists('id'); $last = count($tags) - 1; foreach ($tutorials as $tutorial) { $tutorial->tags()->attach($tags[rand(0, $last)]); } foreach ($tutorials as $tutorial) { $tutorial->tags()->attach($tags[rand(0, $last)]); } foreach ($tutorials as $tutorial) { $tutorial->tags()->attach($tags[rand(0, $last)]); } }
public function run() { $qas = Qa::all(); $tags = Tag::lists('id'); $last = count($tags) - 1; foreach ($qas as $qa) { $qa->tags()->attach($tags[rand(0, $last)]); } foreach ($qas as $qa) { $qa->tags()->attach($tags[rand(0, $last)]); } foreach ($qas as $qa) { $qa->tags()->attach($tags[rand(0, $last)]); } }
public static function getIDs() { return Tag::lists('id'); }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $tags = Tag::lists('name', 'id'); $article = Article::find($id); return View::make('articles.edit', compact('article', 'tags')); }