mercredi 24 avril 2019

Laravel : throw new MethodNotAllowedHttpException($others);

After much research on this forum, but elsewhere on the Internet, "Cat got your tongue".

Many messages speak about this subject, but I can not correct my mistake on my side.

I use the same form to add or modify my data.

I have an error with my form only when I want to modify my data.

Wep.app :

// Gérer les personnes (sociétés, personnes...) photographiées
Route::get('tiers', 'tiersController@afficheliste'); // Fait
Route::get('tiersajouter', 'tiersController@ajouter'); // Fait
Route::post('tiersmodifier', 'tiersController@modifier'); // Fait
Route::post('tiersupdatesql', 'tiersController@updatesql'); // Fait
Route::post('tierssupprimer', 'tiersController@supprimer'); // Fait
Route::post('tiersreactiver', 'tiersController@reactiver'); // Fait

ctrltiersRequest :

<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;

class ctrltiersRequest extends FormRequest {
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize() {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
     public function rules() {
          return [
               'tiersNom'      => 'required|min:5',
               'ville'         => 'required',
               'tiersiptc1'    => 'required',
               'tiersiptc2'    => 'required'
          ];
     }
     public function messages() {
          return [
               'tiersNom.required'       => "Le nom est obligatoire",
               'tiersNom.min'            => "Le nom doit faire au minimum 5 caractères",
               'ville.required'          => "La ville est obligatoire",
               'tiersiptc1.required'     => "Le thème principal est obligatoire",
               'tiersiptc2.required'     => "Le sous-thème est obligatoire"
          ];
    }
}?>

tiersModif.blade :

I can not paste the contents of my blade file into this message. I add it in a reply to this message. I am sorry...

tiersControllers :

 public function updatesql(ctrltiersRequest $request) {
    //public function updatesql(tiersRequest $request) {
         //['tiers_id' => (int)$request->tiersModif],
        $tiers = tiers::updateOrCreate(
            ['tiers_id' => $request->tiersModif],
            ['tiers_nom'                => $request->tiersNom,
             'tiers_prenom'             => $request->tiersPrenom,
             'tiers_societeproduction'  => $request->production,
             'tiers_ville'              => $request->ville,
             'tiers_iptc1'              => $request->tiersiptc1,
             'tiers_iptc2'              => $request->tiersiptc2,
             'tiers_iptc3'              => $request->tiersiptc3]);
        // Afficher
        return Redirect('tiers');



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire