I wanna display data with specefic ID in laravel using vuejs. I get the ID from the link but it seems that there is no request sent to the controller. api.php :
<?php
use Illuminate\Http\Request;
Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user();
});
Route::resource('user','API\UserController');
Route::resource('departement','API\DepartementController');
Route::resource('specialite','API\SpecialiteController')->parameters(['specialite'=>'id']);
my controller :
public function show($id)
{
$specialite=Specialite::with('dep')->findOrFail($id);
$spec = Specialite::with('dep')->where('id',$specialite)->get();
return $spec;
}
my view :
<script>
export default {
data(){
return{
specialites:{},
form: new Form({
id:'',
name:'',
user_id:'',
bio:''
}),
id:0,
}
},
methods: {
loadspecialite(){
//axios.get('api/user').then(({data})=>(this.enseignants=data.data));
axios.get('api/specialite/'+this.id).then(response=>{this.specialites=response.data;});
},
created() {
this.id=this.$route.params.id;
this.loadspecialite();
Fire.$on('AfterCreate',()=>{
this.loadspecialite();
})
}
}
</script>
Hope you'll help me. thank you.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire