mercredi 5 octobre 2016

RelationNotFoundException in RelationNotFoundException.php

each product hasMany property.

when I use with function:

dd(Product::with(ProductProperty::class)->get());

I got this error :

RelationNotFoundException in RelationNotFoundException.php 
Call to undefined relationship [App\Models\ProductProperty] on model [App\Models\Product].


class Product extends Model
{
    protected $table = 'products';


    protected $fillable = [
        'user_id' ,'brand_id' , 'title', 'price', 'current_buy','max_buy','min_buy_per_bill',
        'max_buy_per_bill','count','off','seri','short_description','long_description',
    ];



    public function ProductProperty()
    {
        return $this->hasMany('App\Models\ProductProperty');
    }
}


class ProductProperty extends Model
{
    protected $table = 'products_properties';

    protected $fillable = [
        'product_id' ,'parent_id' , 'title','value', 'price', 'current_buy','max_buy','min_buy_per_bill',
        'max_buy_per_bill','count','off','seri','short_description','long_description',
    ];

    public function Product()
    {
        return $this->belongsTo('App\Models\Product');
    }
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire