Laravel 9 - Cannot get datas from foreign id

Viewed 35

I'm creating a shop, with products and shopping cart.

The products' table name on PHPMyAdmin is called "boutiques". The Shopping Cart's table name on PHPMyAdmin is called "paniers". Here are they :

BOUTIQUES TABLE :

enter image description here

PANIERS TABLE :

enter image description here

As you can see on the "paniers" table, I get foreign ids back from "boutiques" table, especially idproduit (id from "boutiques" table). I'm trying to get back information like "nom", "description" etc from "boutiques" table according to the idpanier from "paniers" table.

I tried this request :

$produits = Boutique::where('idproduit', '=', 'idpanier')->get(['idproduit', 'nom','description', 'prix', 'img']);
        dd($produits);

But it's empty... where did I go wrong ? Thanks for your help !

MODEL PANIER :

class Panier extends Model
{
    protected $fillable  = [
        "idpanier",
        "iduser",
        "idproduit",
        "quantité",

    ];
    use HasFactory;
}

MODEL BOUTIQUE :

class Boutique extends Model
{

    protected $fillable  = [
        "iduser",
        "idproduit",
        "nom",
        "description",
        "prix",
        "img",
        "quantité",
    ];
    use HasFactory;
}
0 Answers
Related