Monday, April 3, 2017

Laravel internal links

I'm looking for some code example which make keyword from post into internal link.

In post table I have body attribute where is text of post. And I make extra table "keyword" where is word and URL attributes.

So i need script which will automatically recognize word which is adding in table "keywords" and found this word in post text and turn this word to hyperlink. Can you guys help me, please?

use App\Post;
use App\Category;
use App\Keyword;


public function getSingle($slug) {
    // fetch from the DB based on slug
    $categoriesall = Category::all();
    $post = Post::where('slug', '=', $slug)->first();

    // return the view and pass in the post object
    return view('news.single')->withPost($post)->withCategoriesall($categoriesall);
}



via Nenad Hamburgerijofil Cerovec

Advertisement