Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

difficulty previewing url #482

Open
Temian1 opened this issue Apr 11, 2022 · 1 comment
Open

difficulty previewing url #482

Temian1 opened this issue Apr 11, 2022 · 1 comment

Comments

@Temian1
Copy link

Temian1 commented Apr 11, 2022

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

@oscarotero
Copy link
Owner

Sorry I'm not familiarized with Laravel so cannot help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants