예제 #1
0
 /**
  * Should have a belongs-to-many relationship with Images.
  */
 public function testImages()
 {
     $images = $this->product->images();
     $this->assertInstanceOf(BelongsToMany::class, $images);
     $this->assertEquals('images', $images->getRelationName());
 }
예제 #2
0
 /**
  * @param Product $product
  *
  * @return Image
  */
 protected function attachImageToProduct(Product $product) : Image
 {
     $image = Image::create(['alt_text' => str_random(), 'url' => $this->generator()->anySlug()]);
     $product->images()->attach($image->id);
     return $image;
 }