Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 2 years ago.
0

What is the code that performs the update?

Usually just calling the save method on your model should do the trick.

Last updated 2 years ago.
0
$specifications = Specifications::updateOrCreate(array('id' => $id)+(Input::only('motor_type')));
		return Redirect::to('control/motorcycles');
Last updated 2 years ago.
0

You should have a comma instead of the '+' sign, the signature for updateOrCreate is

static Model updateOrCreate(array $attributes, array $values = array())

The first argument being an array of attributes to match one or multiple records (in your case, the id will match only one), The second argument, is an array of values, in the form of [field => value] which are the properties and the values with which you want to update your model(s).

So, basically you should use the following line of code :

$specifications = Specifications::updateOrCreate(array('id' => $id), Input::only('motor_type'));

And it should do the trick. Hope that helps.

Last updated 2 years ago.
0

Thank you a lot! It works perfectly, just how I want.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.