Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

StuffedGoat's avatar

Project Flyer Ep. 16 - Two errors

Hi!

I'm following Jeffreys Project Flyer and now in episode 16 I'm stuck because I get this error when I want to create a new flyer:

ErrorException in FlyersController.php line 52:
Undefined variable: flyer

& when I when I want to add photos I get his one:

Call to undefined method Illuminate\Database\Query\Builder::fileName()
at Model->__call('fileName', array()) in AddPhotoToFlyer.php line 46
at Photo->fileName() in AddPhotoToFlyer.php line 46

I rewatched the video several times but I don't find the error which is very frustrating. Maybe someone has it on Github and can point me there? :) I found repositories but unfortunately they are outdated.

Anyway, here are my methods, they look exactly like in Jeffreys video:

// Line 52 is the return statement
public function store(FlyerRequest $request)
{
    $this->user->publish(
        new Flyer($request->all())
    );
    return redirect(flyer_path($flyer));
}

// The helper class:
function flyer_path(App\Flyer $flyer)
{
    return $this->zip .'/'. str_replace(' ', '-', $this->address);
}

And line 46 from my second error looks like this.

public function save()
{
    $photo = $this->flyer->addPhoto($this->makePhoto());

    $this->file->move($photo->baseDir(), $photo->name);

    $this->thumbnail->make($photo->path, $photo->thumbnail_path);
}

Does anyone also encountered this/these errors and could give me some advice? Unfortunately I cannot find this project under Jeffreys Github account :(

Happy Weekend!

0 likes
5 replies
bobbybouwmann's avatar

Jeffrey will probably put the code online when the serie is finished ;)

Now for your first problem, your code isn't creating any $flyer variable. I didn't follow the tutorial but I think you need this

public function store(FlyerRequest $request)
{
    $flyer = $this->user->publish(
        new Flyer($request->all())
    );

    return redirect(flyer_path($flyer));
}
2 likes
thomaskim's avatar

In addition to that, the second error is happening because he refactored a lot. I think he removed the fileName() method and changed $photo->fileName() to just $photo->name.

2 likes
StuffedGoat's avatar

Thank you very much!

Maybe it's already to late that I didn't not saw this anymore but in my defense,.. this was really sneaking! ;-)

bobbybouwmann's avatar

Yeah, Jeffrey goes pretty fast through the stuff, glad we have that pause button ;)

Please or to participate in this conversation.