0
I am using the Laravel Repository in my project. I created a Service to add some rules. In the upload method it is a reusable method for both saving and updating images. The save method works perfectly with the upload method. The update method does the upload process but does not save the data in the database. Qnd I get the image data in the upload method they arrive as follows:
Dps that they upload and returns the data with the renamed file name returns so:
Saving method:
public function save($files, $id)
{
$arr = $this->doUpload($files);
foreach($arr as $entry)
{
$entry->projects_id = $id->id;
$entry->save();
}
return;
}
Update method that happens nothing:
public function updateImage($files, $id)
{
$arr = $this->doUpload($files);
foreach ($arr as $key) {
$key = array(
'filename' => $key->filename,
'original_filename'=> $key->original_filename,
'mime'=> $key->mime,
);
}
return $this->uploadsRepository->update($arr, $id);
}
And I tried that too:
public function updateImage($files, $id)
{
$arr = $this->doUpload($files);
foreach ($arr as $key) {
$this->uploadsRepository->update($key, $id);
}
return ;
}
That returns the error:
Argument 1 passed to Prettus Repository Eloquent Baserepository::update() must be of the type array, Object Given, called in C: projetos painel app Services Projectservice.php on line 45 and defined