Home > other >  How to STR Replace and echo in laravel
How to STR Replace and echo in laravel

Time:02-08

Files that are uploaded to my site have their names changed and extention change to bin. So for example a uploaded file will be dfd84848.bin, using the bin file worked fine with modelviewer but im trying to test babylon.js and it doesnt work with .bin only if i change .bin to .glb.

This code {{uploaded_asset($detailedProduct->cad_file)}} provides link like uploads/all/p1YZX9TBc7EmimFx4rXnSFKvVor8EttpOUUpylLL.bin

I want to change .bin to .glb and echo it.

i tried this

@php
    $previewfile = uploaded_asset($detailedProduct->cad_file);
    $replaced = Str::replace('.bin', '.glb', $previewfile );
@endphp

to show i used this <model url="{$replaced}"> but it never echoed url

Edit

So now that it echos as name.glb it doesnt work because the file doesnt exist on server. When 3d models such as .glb, .gltf are uploaded they are renamed to .bin i dont know why. The uploader is AizUploadController.php

CodePudding user response:

To echo a value you should use double curly braces:

<model url="{{ $replaced }}">

Docs: https://laravel.com/docs/8.x/blade#displaying-data

  •  Tags:  
  • Related