如何在laravel 5.7中获取当前视图名称(页面名称)

时间:2018-11-02 11:58:11

标签: laravel url routes

我有一条这样的路线http://localhost:8000/admin/edit-profile/13 我的页面名称是edit-profile.blade.php 而且我只想从这条路线上看到edit-profile。 任何想法如何完成这项任务? 任何帮助将不胜感激...

3 个答案:

答案 0 :(得分:1)

您可以使用import { HttpClient, HttpHeaders } from '@angular/common/http'; let headers = new HttpHeaders({ 'Content-Type': 'application/json' }); let options = { headers: headers } this.http.post(URL, param, options) .subscribe(data => { console.log(data); }); // For pass blob in API return this.http.get(url, { headers: new HttpHeaders({ 'Authorization': '{data}', 'Content-Type': 'application/json', }), responseType: 'blob'}).pipe ( tap ( // Log the result or error data => console.log('You received data'), error => console.log(error) ) ); 来获取Request::segment()的任何片段,例如:

url()

Reference

答案 1 :(得分:0)

您应该尝试以下操作:

控制器

public function editProfile($id){
 $rsltTest = yourModelName::find($id);
 return view('edit-profile',compact('rsltTest'));

}

路线

Route::get('edit-profile/{id}', 'ProfileController@editProfile')->name('edit-profile');

答案 2 :(得分:0)

You can pass the reference like this one, but still you need the id in the url either before edit or after edit depends upon your route -

public function editProfile(ModelClass $id){ //$id holds all the data as per the id
 $data = $id;
 return view('edit-profile',compact('data'));

}
相关问题