Hi, i update to latest version of this package(5.12.0), but now, i can´t get/download uploaded files. The Upload part its ok, i can see the data in database, its ok.
But if i try to download the files it gives this error:
Type error: Argument 1 passed to Spatie\MediaLibrary\MediaRepository::getCollection() must be an instance of Spatie\MediaLibrary\HasMedia\Interfaces\HasMedia, instance of App\Models\Extras\Curriculo given, called in /var/www/popmanager/backend/vendor/spatie/laravel-medialibrary/src/HasMedia/HasMediaTrait.php on line 201
My model:
<?php
namespace App\Models\Extras;
use Illuminate\Database\Eloquent\Model;
use Spatie\MediaLibrary\HasMedia\HasMediaTrait;
use Spatie\MediaLibrary\HasMedia\Interfaces\HasMedia;
class Curriculo extends Model {
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'curriculos';
use HasMediaTrait;
}
My call:
public function getCurriculo($id) {
$curriculo = Curriculo::find($id);
$anexos = $curriculo->getMedia('curriculos');
$curriculo_url = $anexos[0]->getPath();
return (new Response($curriculo_url, 200))->header('Content-Type', $anexos[0]->mime_type);
}
Pretty sure this is not caused by upgrading the package but by the fact
that your model doesn't implement the HasMedia interface.
Add 'implements HasMedia' after your class declaration.
On Thu, 8 Jun 2017 at 18:45, Bruno Cavalcante Barbosa <
[email protected]> wrote:
Hi, i update to latest version of this package(5.12.0), but now, i can´t
get/download uploaded files. The Upload part its ok, i can see the data in
database, its ok.But if i try to download the files it gives this error:
FatalThrowableError
Type error: Argument 1 passed to Spatie\MediaLibrary\MediaRepository::getCollection() must be an instance of Spatie\MediaLibrary\HasMedia\Interfaces\HasMedia, instance of App\Models\Extras\Curriculo given, called in /var/www/popmanager/backend/vendor/spatie/laravel-medialibrary/src/HasMedia/HasMediaTrait.php on line 201My model:
namespace App\Models\Extras;
use Illuminate\Database\Eloquent\Model;
use Spatie\MediaLibrary\HasMedia\HasMediaTrait;
use Spatie\MediaLibrary\HasMedia\Interfaces\HasMedia;class Curriculo extends Model {
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'curriculos';use HasMediaTrait;}
My call:
public function getCurriculo($id) {
$curriculo = Curriculo::find($id); $anexos = $curriculo->getMedia('curriculos'); $curriculo_url = $anexos[0]->getPath(); return (new Response($curriculo_url, 200))->header('Content-Type', $anexos[0]->mime_type); }—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/spatie/laravel-medialibrary/issues/654, or mute the
thread
https://github.com/notifications/unsubscribe-auth/AAdiDbDT4gJCJKy0yw_74975EFZjwqxVks5sCCUngaJpZM4N0Vbi
.>
Freek Van der Herten https://spatie.be +32 495 84 27 91
Most helpful comment
Pretty sure this is not caused by upgrading the package but by the fact
that your model doesn't implement the HasMedia interface.
Add 'implements HasMedia' after your class declaration.
On Thu, 8 Jun 2017 at 18:45, Bruno Cavalcante Barbosa <
[email protected]> wrote:
Freek Van der Herten https://spatie.be +32 495 84 27 91