I've spent practically all day trying to nut this one out, I need some help. I've finished lesson 16 and when I try to upload an image to a flyer I get the error 'Call to a member function addPhoto() on null'.
My PhotosController.php
public function store($zip, $street, ChangeFlyerRequest $request)
{
$flyer = Flyer::locatedAt($zip, $street);
$photo = $request->file('photo');
(new AddPhotoToFlyer($flyer, $photo))->save();
}
I've dumped both the $flyer and the $photo and get expected results. However, both the $flyer and $photo become null after creating the AddPhotoToFlyer object.
My save function inside the AddPhotoToFlyer.php
public function save()
{
$photo = $this->flyer->addPhoto($this->makePhoto());
$this->file->move($photo->baseDir(), $photo->name);
$this->thumbnail->make($photo->path, $photo->thumbnail_path);
}
Any help would be greatly appreciated.