Skip to content

difficulty previewing url #482

Open
Open
@Temian1

Description

@Temian1

I am on laravel 9 in my show blade I am trying to display any URL posted by a user here is my code

in my livewire post show blade I did this if I create a post with a link the is not previewing in my show view page , I have tried to different URL still not working

public function mount (Post $post)
{
     $this->post = $post;
   
    preg_match_all('#\bhttps?://[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#', $post->body, $matches);
    $this->urlDetails = collect($matches[0])->map(function ($url) {
       $embed = new Embed();
       $info = $embed->get($url);
		return ['info' => $info, 'title' => $info->title];  
    })->all();
}

getting the URL like this in my show blade view

{{ $urlDetails['title'] ?? '' }}

but it's not working

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions