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

FitsumMulatu's avatar

PHP error: Undefined variable: flyer on line 1

i am following Build “ProjectFlyer” With Me series. On episode 7 -> The Flyer and Photos Relationship. when i type $flyer->photos; i get an error ....plz help me $ php artisan tinker

$flyer->photos; PHP error: Undefined variable: flyer on line 1

0 likes
2 replies
FitsumMulatu's avatar
FitsumMulatu
OP
Best Answer
Level 1

when i type $flyer=factory('App\Flyer')->create(); and then $flyer->photos()->create(['photo' => 'foo.jpg']); and then $flyer->photos(); it works.

Please or to participate in this conversation.