Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How I can store url in database Laravel

In laravel 5.4 , When I want to use url I've to config in web.php ex

Route::get('/test/{id}', function () {
    return view('frontend/test/{id}');
});

Is their anyway to store path into database and use It with out maunal config in web.php

for example I want to change /test/1, /test/2 to test/test1 , test/test2

which I can Update delete in database In my database I've url path

test1

test2
like image 238
test1321 Avatar asked Nov 01 '17 09:11

test1321


1 Answers

If the name is stored within the database simply change:

<a href="link/{{ $variable->id }} to <a href="link/{{ $variable->name }}

Then change your route from:

Route::get('/test/{id}', function () {
    return view('frontend/{id}');
});

to

Route::get('/test/{name}', function () {
    return view('frontend/{name}');
});
like image 130
Option Avatar answered Sep 20 '22 21:09

Option