我为我的应用程序开发了几个页面。现在我需要为这些页面添加链接。直到现在我通过网址浏览打开这些页面。
我的web.php页面
// for books
Route::get('/book','BookController@create');
Route::post('/book','BookController@store');
Route::get('/book/{id}','BookController@edit');
Route::patch('/book/{id}', 'BookController@update');
// for ordered books
Route::get('/order','OrderedBookController@create');
Route::post('/order','OrderedBookController@store');
Route::get('/billSearch','OrderedBookController@searchBill');
Route::post('/billSearch','OrderedBookController@billPay');
Route::post('/billSearch/{id}', 'OrderedBookController@pay');
// for Books Out
Route::get('/booksout','BooksOutController@create');
Route::post('/booksout','BooksOutController@store');
与路径对应的页面列表
book.blade.php
edit.blade.php
booksin.blade.php
booksout.blade.php
本地主机网址浏览这些页面是::
http://127.0.0.1:8000/book
http://127.0.0.1:8000/order
http://127.0.0.1:8000/billSearch // for Route::get('/billSearch','OrderedBookController@searchBill');
http://127.0.0.1:8000/booksout
如何在我的网络应用程序中创建链接,因为我通过路线而不是通过页面浏览我的页面?
只需插入这样的路线:
<a href="/book">Book</a> --> http://127.0.0.1:8000/book
<a href="/billSearch ">Bill Search</a> --> http://127.0.0.1:8000/billSearch
您可以使用以下两种方法之一链接laravel中的不同页面
1:通过在刀片href中包含您在路径中定义的URL
Route::post('/billSearch', 'OrderedBookController@pay');
因此在你的刀片链接
<a href="/billSeach"> </a>
2:使用路线名称
Route::post('/billSearch', 'OrderedBookController@pay')->name('bill);
因此在您的刀片视图中
<a href="{{route('bill'}}"></a>