简体   繁体   中英

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

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}');
});

将URL的硬核保存在控制器中,并从控制器动态更新ID

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM