Heimdall
1 month ago
772
18
General

update BDD

Posted 1 month ago by Heimdall

Hello,

i have little problem with update on my BDD: my problem is :

i have 2 table : 1 table = chiens and 1 table images

I want edit information on my form, so for edit the name etc i use my table chiens :

public function update(chien $chien, Request $request, image $image)
{


          $nom = request("nom");
          $race = request("race");
          $ententechien = request("ententechien");
          $ententechat = request("ententechat");
          $caractere = request("caractere");
          $datecome = request("datecome");
          
         
          $chien -> name = $nom;
          $chien -> race = $race;
          $chien -> Ententechien = $ententechien;
          $chien -> Ententechat = $ententechat;
          $chien -> caractere = $caractere;
          $chien -> update();   

and on this form i can change the image to, so i use this code for update my table image:

public function update(chien $chien, Request $request, image $image) {

          $nom = request("nom");
          $race = request("race");
          $ententechien = request("ententechien");
          $ententechat = request("ententechat");
          $caractere = request("caractere");
          $datecome = request("datecome");
          
         
          $chien -> name = $nom;
          $chien -> race = $race;
          $chien -> Ententechien = $ententechien;
          $chien -> Ententechat = $ententechat;
          $chien -> caractere = $caractere;

          $chien -> update();   
        
   


        $idpublication = 0;
        $id_chien = $chien->id;
          
          if($request->hasfile('imagefirst'))
          {
            $image -> id_publication = $idpublication;
            $image -> id_chien = $id_chien;
            $file = $request->file('imagefirst');
            $extension = $file->getClientOriginalExtension();
            $filename = time() . '.' . $extension;
            $file->move('images/', $filename);
            $image-> image = $filename;
            dd($request->file('imagefirst'));
        } 

        $image -> update();   
    
}

my first update on table chiens work correctly, but my second update with the table image dont work and i dont know why

If you can help me :)

Ty

Please sign in or create an account to participate in this conversation.