vendredi 27 mai 2016

How to get uri address of a nested resources using vue js and laravel

I am having problem fetching the uri of a nested resource when using vue js. See below code.

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

The problem here is, getting the value of the id of this url http://localhost:8000/reservation/id/student. Is there a way to get the id of the parameter of the index() method? Also here's my route list http://ift.tt/25q6BYA



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire