0

Creating default object from empty value

$w = new item;

            $w->order_id = Input::get('order_id');
            $w->user_id = Input::get('user_id');
            $w->item_id = Input::get('item_id');

            $w->save();

I'm trying to insert the values into w table it says me to Creating default object from empty value i don't know why object is null how to fixed it out

3
  • What's your 'model' called? You can't just use a model named 'model', as this will be the abstract Model class. Also make sure these attributes are inside the 'fillable' array in your model. Commented Sep 14, 2016 at 11:43
  • model name is item protected $fillable = [ 'order_id', 'user_id', 'item_id', ]; Commented Sep 14, 2016 at 11:54
  • I think your model should be Item(first letter uppercase). Commented Sep 14, 2016 at 14:15

1 Answer 1

1

Try this:

$w = item::create(array('order_id' => Input::get('order_id'), 'user_id' => Input::get('user_id'), 'order_id' => Input::get('item_id')));
Sign up to request clarification or add additional context in comments.

Comments

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.