Try saving, see https://laravel.com/docs/8.x/eloquent#updates
Feb 7, 2022
13
Level 2
Laravel Model not updating.
I am facing a weird problem where Laravel Model is not updating data. I have tried using eloquent, raw queries but nothing works. It was working well but it just stopped, I don't know when. When I update, it returns a success message but no data is saved. All the fields are defined in the fillable.
here is my model:
class Jewel extends Model
{
use SoftDeletes;
protected $table = 'jewel';
protected $casts = [
'supplier_id' => 'int',
'selected_properties'=>'array',
'matching_item_codes'=>'array',
'diamond_shapes'=>'array',
'selected_tags'=>'array',
'max_carat'=>'float',
'min_carat'=>'float',
'setting_type' => 'int',
'updated_by' => 'int'
all others
...
];
protected $fillable = [
'supplier_id',
'discount_id',
'item_code',
'parent_id',
'centerstone_id',
'design_code',
'product_title',
all others
...
]
Controller Code:
public function updateJewels(Request $request, $id)
{
$jewelry = Jewel::find($id);
// dd($request->all());
$jewelry->update([
'product_desc'=>$request->product_desc,
'product_short_desc'=>$request->product_short_desc
]);
}
It returns a success message but no data is updated.
Please or to participate in this conversation.