I just want to initialize properly an object :
namespace App;
class Produit
{
public $nb_serveurs;
public $type;
public $duree;
public function __construct($nb_serveurs, $type, $duree){
$this->$nb_serveurs = $nb_serveurs;
$this->$type = $type;
$this->$duree = $duree;
}
}
Then in my controller :
class ProductController extends Controller
{
public function addToCard (Request $request){
$nb_serveurs = $request->nb_serveurs;
$type = $request->type;
$duree = $request->duree;
$panier = new Panier();
$product = new Produit($nb_serveurs, $type, $duree);
dd($product);
$panier->addItem($product, 1);
}
}
The dd function give me this :
Produit {#149 ▼
+nb_serveurs: null
+type: null
+duree: null
+"2": "2"
+"5": "5"
}
i tested out, the 3 variables are not null.. What's wrong here ? And what are the 2 last lines in the Produit object ?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire