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

tgif's avatar
Level 4

Laracast - bulk file uploads - syntax question

Hi guys, Jeff has this line of code in the controller that is throwing me off. He uses 2 curly brackets on the final line to encapsulate var $name. Is that Blade within the php code???

public function addPhoto($zip, $street, request $request) {
    $file = $request->file('file');
    $name = time() . $file->getClientOriginalName();
    $file->move("flyers/photos", $name);
    $flyer = Flyer::locatedAt($zip, $street)->first();

    $flyer->photos()->create(['path' => "/flyers/photos/{$name}"]);
}
0 likes
3 replies
karlos545's avatar
Level 9

thats just the syntax you use to reference a variable in a string :) @csuarez

2 likes
tgif's avatar
Level 4

Thank you guys @karlos545 @freekmurze .

To avoid this syntax wouldn't this be a good idea?

$flyer->photos()->create(['path' => $name]);

and then in the layout

<img src="/flyers/photos/ { { $name } } " alt="" />

Please or to participate in this conversation.