我有以下获取请求,该请求在 mount()上执行。 当我明确地从数据库请求一些数据时,以某种奇怪的神秘方式,我回到主视图 app.blade 作为响应。
有人可以发现我搞砸了吗?
我的获取请求在前端:
$app->group('/backend', function () {
$this->get('/dashboard.html', 'BackendDashboardController:index')->setName('backend');
});
$app->get('/[{path:.*}]', function($request, $response, $path = null) { return $response->write($path ? 'subroute' : 'index'); });
我的路线:
mounted() {
this.getProjectRequests();
},
methods: {
getProjectRequests: function() {
var self = this;
let clientId = this.$route.path.substring(
this.$route.path.lastIndexOf("/") + 1
);
axios({
method: "get",
url: "/get-project-requests/" + clientId
})
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log(error);
// TODO error handling
});
}
}
和我的控制器方法:
Route::get('/get-project-requests/{client_id}',
'SinglePageController@getProjectRequests');
答案 0 :(得分:0)
我认为这ProjectRequest::where('client_id', $clientId)->value('name');
例外。
您可以在 storage / logs 文件夹中查看 laravel.log ,或将该方法更改为
// Not working on eloquent model
$valueOject = ProjectRequest::where('client_id',$clientId)->value('name');
// DB facade its working. Change to this method
$valueOject = DB::table('{your_table}')->where('client_id', $clientId)->value('name');
dd($valueOject);