J'ai trouvé le problème avec mon code, mais je ne sais toujours pas pourquoi 500 erreur ne se connecte pas au stockage/journal, ne sais toujours pas pourquoi page blanche, et ne sais toujours pas comment résoudre ce problème.
Le problème est lorsque je supprime facture_produit dans protect $ avec tableau, l'erreur disparue.
Voici le code que je modifie.
//protected $with = ['invoice_products', 'customer', 'currency', 'company'];
//Comment out above line, the below line is working
protected $with = ['customer', 'currency', 'company'];
Je crois que ma relation est mauvaise, mais ne trouve pas le problème,
Voici mon code pour "modèle purchasing_orders" modèle Eloquent, qui ont beaucoup de "invoice_products"
class PurchasingOrder extends Model
{
protected $table = 'purchasing_orders';
protected $fillable = [
'po_number', 'po_date',
'invoice_reference', 'customer_id', 'customer_po_number', 'agent',
'estimate_shipping_date', 'estimate_arrival_date', 'estimate_loading_date',
'ship_to','to_user_name',
'term', 'po_remark', 'worksheet_remark',
'company_id','currency_id',
'total_amount', 'total_quantity','total_net_weight','total_gross_weight','total_packed_cu_metric','total_pallets',
];
//Json come with product_unit and supplier that associated with prdocut
//protected $with = ['invoice_products', 'customer', 'currency', 'company'];
protected $with = ['customer', 'currency', 'company'];
/**
* Get the invoice_product of invoice.
*/
//One invoice has many invoice_product
public function invoice_products()
{
return $this->hasMany('App\InvoiceProduct');
}
/**
* Get the customer of invoice.
*/
//One invoice has only one customer
public function customer()
{
return $this->belongsTo('App\Customer', 'customer_id');
}
/**
* Get the currency of invoice.
*/
//One invoice has only one currency
public function currency()
{
return $this->belongsTo('App\Currency', 'currency_id');
}
/**
* Get the company of invoice.
*/
//One invoice has only one company
public function company()
{
return $this->belongsTo('App\Company', 'company_id');
}
Et voici mon code de "invoice_products" Modèle éloquent (appartenant à purchase_order Eloquent modèle)
class InvoiceProduct extends Model
{
protected $table = 'invoice_products';
protected $fillable = [
'product_id', 'customer_product_id','name', 'brand', 'packing',
'gross_weight', 'net_weight','net_weight_packing',
'product_unit_id', 'packed_cu_metric',
'quantity','price','amount','pallets',
'invoice_id', 'purchasing_order_id','container_id',
];
//Json come with InvocieProduct add PurchasingOrder
protected $with = ['purchasing_order', 'product', 'customer_product', 'container'];
public function purchasing_order()
{
return $this->belongsTo('App\PurchasingOrder', 'purchasing_order_id');
}
public function container()
{
return $this->belongsTo('App\Container');
}
public function product()
{
return $this->belongsTo('App\Product', 'product_id');
}
public function customer_product()
{
return $this->belongsTo('App\CustomerProduct', 'customer_product_id');
}
}
Merci pour votre réponse, mais j'ai toujours eu la même erreur avec ou sans -> get(). Au début, lorsque la table InvoiceProducts est vide fonctionne correctement, mais après avoir ajouté un enregistrement, l'outil de développement Chrome renvoie erreur 500, mais rien dans Laravel Debuggar aussi lorsque j'essaie de rafraîchir après erreur, maintenant la page blanche apparaît –