mercredi 31 mai 2017

Laravel use query result in controller function

here is a part of the function in my controller

    $res= Commande::where('idClient',$id)->where('created_at',$datejour)->where('adresse',$addr)->get();
    if($res->isEmpty())
    {...
    }
    else
    {
        try {
        $resultat =\DB::table('ligne_commandes')->insert(['idCom'=>$res->idCom,'nomChaussure'=>$nomChaussure,'marque'=>$marque,'couleur'=>$couleur,'quantite'=>'1','pointure'=>$point]);
        return redirect()->back()->withErrors('Vous serez livrée dans un délai de 48 heures');
        }

        catch (\Illuminate\Database\QueryException $e) {
        return redirect()->back();

        }
    }

}

when i try to use $res->idCom, i got this error Property [idCom] does not exist on this collection instance. can someone help me?



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

Aucun commentaire:

Enregistrer un commentaire