Tipo de error: el argumento 2 pasó a la aplicación \ AddPhotoToProduct :: __ construct () debe ser una instancia de la aplicación \ Uploaded,

Estoy obteniendo el error del argumento inválido 2 y estoy tratando de subir varias imágenes a través de dropzone.

[ERROR] FatalThrowableError en AddPhotoToProduct.php línea 30: Tipo de error: Argumento 2 pasado a App \ AddPhotoToProduct :: __ construct () debe ser> una instancia de App \ Uploaded, array given, llamado en> C: \ xampp \ htdocs \ mid_login1 \ app \ Http \ Controllers \ ProductPhotoController.php on> línea 37

ProductPhotoController.php

namespace App\Http\Controllers; use App\Product; use App\ProductPhoto; use App\AddPhotoToProduct; use Illuminate\Http\Request; Use App\Http\Controllers\Controller; use Illuminate\Support\Facades\Input; class ProductPhotoController extends Controller { /** * @param $id * */ public function store($id,Request $request) { $product = Product::LocatedAt($id); $file = $request->file('file'); (new AddPhotoToProduct($product,$file))->save(); } } 

Y mi modelo AddPhotoToProduct.php

 namespace App; use Symfony\Component\HttpFoundation\File\UploadedFile; class AddPhotoToProduct { /** * @var Product */ protected $product; /** * The UploadedFile Instance. * * @var UploadedFile */ protected $file; /** * Create a new AddPhotoToProduct form object. * * @param Product $product * @param UploadedFile $file * @param Thumbnail|null $thumbnail */ public function __construct(Product $product, Uploaded $file, Thumbnail $thumbnail = null) { $this->product = $product; $this->file =getName($file); $this->thumbnail = $thumbnail ?: new Thumbnail; } /** * Process the form. */ public function save() { // Attach the photo to the product. $photo = $this->product->addPhoto($this->makePhoto()); // move a file to the base directory with the file name. $this->file->move($photo->baseDir(), $photo->name); // Generate a photo thumbnail. $this->thumbnail->make($photo->path, $photo->thumbnail_path); } /** * Make a new Photo Instance. * * @return ProductPhoto */ protected function makePhoto() { return new ProductPhoto(['name' => $this->makeFilename()]); } /** * Make a Filename, based on the uploaded file. * * @return string */ protected function makeFilename() { // Get the file name original name // and encrypt it with sha1 $name = sha1 ( time() . $this->file->getClientOriginalName() ); // Get the extension of the photo. $extension = $this->file->getClientOriginalExtension(); // Then set name = merge those together. return "{$name}.{$extension}"; } } 

form-uploads.blade.php

 
id }}/photo" class="dropzone" id="addProductImages"> {{ csrf_field()}}

Código de archivo de rutas

  Route::post('/admin/products/{id}/photo','ProductPhotoController@store'); 

$ request-> file es una instancia de FileBag y no una instancia de App / Uploaded, debería echar un vistazo a Symfony Doc sobre el Componente HttpFoundation para comprender mejor cómo funciona.

 class ProductPhotoController extends Controller { /** * @param $id * */ public function store($id,Request $request) { $product = Product::LocatedAt($id); $files = $request->file('file'); foreach ($files as $file) { (new AddPhotoToProduct($product,$file))->save(); } } }