I want to fetch topics from my data base but want to show name of the topic in lower case with underscore in place of any character and space. Right now I am getting data via Id.
Thanks @Vilfago, it worked the problem is now, I have created the slug column in the table but how can I get the content for that page when we click on the url.
foreach ($topics_list as $topics)
{
echo "<li><a href=\"topics/".$topics->slug."\">".$topics->name."</a></li>";
}
How can I send info like it's id through url to fetch it on on new page?
namespace App;
use Illuminate\Database\Eloquent\Model;
class Topics extends Model
{
//Table name
protected $topics = 'topics';
//Primery Key
public $primeryKey = 'id';
//Time Stamps
public $timestamps = true;
}
Controller
public function index()
{
$topics = DB::table('topics')->limit(30)->get();
return view('pages.topics', ['topics' => $topics]);
}
public function showById()
{
$topics = Topics::find($id);
return view('pages.topics', ['topics' => $topics]);
}