vendredi 27 mai 2016

Get url param vue js and laravel

I am having problem fetching the parameter of my route. I am using laravel and vue js

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



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1WrfoVb
via IFTTT

Aucun commentaire:

Enregistrer un commentaire