0

I'm getting this error just by instantiating a Model and setting a property.

$order_datail = new OrderDetail;
$order_detail->quantity = $product['quantity'];

I'm searching for hours for the cause of this problem but can't find it.

The constructor of OrderDetail is executed. table is order_details, but even by setting protected $table = 'order_details', I'm still getting this error. And yes there is a column 'quantity' in this table.

Strange thing is that I've no problem with other models.

$order = new Order;
$order->pickup_date = $request['date'];
$order->pickup_time = $request['pickupTime'];

The above code runs fine.

Model OrderDetail:

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class OrderDetail extends Model
{
use SoftDeletes;

public function replaceds()
{
    return $this->hasMany('App\Models\Replaced');
}
public function orders()
{
    return $this->belongsTo('App\Models\Order');
}
public function products()
{
    return $this->hasMany('App\Models\Product');
}
public function collis()
{
    return $this->hasMany('App\Models\Colli');
}
}

Anyone that knows what can be the cause of this?

4
  • 2
    can you show your model? Commented Aug 13, 2020 at 15:11
  • Sorry, updated the question Commented Aug 13, 2020 at 15:16
  • 2
    Please correct your speling in $order_datail = new OrderDetail; it should be "order_detail" Commented Aug 13, 2020 at 15:23
  • You can't be serious... Checked it so many times. Facepalm! Commented Aug 13, 2020 at 15:32

1 Answer 1

3

There is a spelling error on $order_datail = new OrderDetail; Change it to: $order_detail = new OrderDetail;

Sign up to request clarification or add additional context in comments.

1 Comment

You can't be serious... Checked it so many times. Facepalm!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.