FileUpload doesn't accept MorphTo.
This is the product model:
public function photo(): MorphOne
{
return $this->morphOne(Photo::class, 'photoable');
}
This is the photo model:
public function photoable(): MorphTo
{
return $this->morphTo();
}
This is the resource:
FileUpload::make('photo')
->image()
->placeholder(__('Photo')),
When I upload then the photo table is empty.2 Replies
The
photos
table should have the necessary columns for storing the file data and the polymorphic relation (photoable_id
, photoable_type
). Is that the case?
Polymorphism can be trickyThe photo model has the required fileds:
class Photo extends Model
{
protected $fillable = ['photoable_id', 'photoable_type', 'filename'];
public function photoable(): MorphTo
{
return $this->morphTo();
}
}