vue jsを使用する場合、ネストされたリソースのURIを取得する際に問題が発生しています。下記のコードを参照してください。ここvue jsとlaravelを使用してネストされたリソースのuriアドレスを取得する方法
ReservationController.php
public function index($id)
{
$student = Student::with(['sectionSubjects','sectionSubjects.section',
'sectionSubjects.subject'])->findOrFail($id);
return $student->sectionSubjects;
}
all.js
methods:{
fetchSubjects: function(){
var self = this;
this.$http({
url: 'http://localhost:8000/reservation/id/student',
method: 'GET'
}).then(function (reservations){
this.$set('reservations', reservations.data);
console.log('success');
}, function (response){
console.log('failed');
});
}
}
問題は、このURL http://localhost:8000/reservation/id/studentのIDの値を取得し、です。 index()メソッドのパラメータのidを取得する方法はありますか?私のルートリストもありますhttp://imgur.com/8MWaCpO
アプリを知っている必要がありますあなたがリクエストを送信しようとしているIDなので、httpリクエストで予約を取得する必要があります。 – Jeff
@Jeffええ、それは私の問題です。私はそのIDをフェッチする前に、URIを取得する方法を見つけることができません。あなたは私に例を挙げることができますか? – Jearson