コード例 #1
0
 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)]);
     }
 }
コード例 #2
0
 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)]);
     }
 }
コード例 #3
0
 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)]);
     }
 }
コード例 #4
0
 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)]);
     }
 }
コード例 #5
0
ファイル: Tag.php プロジェクト: rituzy/iblog
 public static function getIDs()
 {
     return Tag::lists('id');
 }
コード例 #6
0
 /**
  * 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'));
 }