public function run() { $imgs = Image::lists('id'); $tags = Tag::all(); foreach ($tags as $tag) { $tag->images()->attach($randValues = array_intersect_key($imgs, array_flip(array_rand($imgs, 2)))); } }
public function run() { $params = Parameter::lists('id'); $tags = Tag::all(); foreach ($tags as $tag) { $tag->params()->attach($randValues = array_intersect_key($params, array_flip(array_rand($params, 2)))); } }
public function run() { $options = Option::lists('id'); $tags = Tag::all(); foreach ($tags as $tag) { $tag->options()->attach($randValues = array_intersect_key($options, array_flip(array_rand($options, 2)))); } }