public function postAnnonce($idCat = null)
 {
     $cat_id = Categorie::select('*')->where('id', '=', $this->request->getParam('cat_id'))->count();
     if ($cat_id == 0) {
         $tab = array('messageErreur' => 'La catégorie est inexistante.');
         $data = json_encode($tab);
         return $this->jsonResponse($data, 404);
     } else {
         $annonce = new Annonce();
         $annonce->titre = $this->request->getParam('titre');
         $annonce->descriptif = $this->request->getParam('descriptif');
         $annonce->ville = $this->request->getParam('ville');
         $annonce->code_postal = $this->request->getParam('codepostal');
         $annonce->prix = $this->request->getParam('prix');
         $annonce->passwd = $this->request->getParam('password');
         if ($idCat == null) {
             $annonce->cat_id = $this->request->getParam('cat_id');
         } else {
             $annonce->cat_id = $idCat;
         }
         $annonce->save();
         return $this->jsonResponse($annonce, 201);
     }
 }
 public function getCategorieByAnnonce($annonce)
 {
     $query = Categorie::join('annonce', 'categorie.id', '=', 'annonce.cat_id')->select('categorie.id', 'categorie.libelle', 'categorie.descriptif')->where('annonce.id', '=', $annonce);
     $categorie = $query->get();
     return $this->jsonResponse($categorie, 200);
 }