laraveleloquentlaravel-models

Eloquent model update returns true but db change not reflecting


I have a model called CustomerInfo and i am trying to update it. update returns true but the changes are not reflecting on my db.

$customerInfo = CustomerInfo::where('machine_name',$username)->firstOrFail();
$result = $customerInfo->update($data);

$data varaible is a array having key value pair. Also tried the following

$customerInfo = CustomerInfo::where('machine_name',$username)->update($data);

Solution

  • Solved my questions. Thanks Luciano. i started eloquent manual db transaction and forgot to commit it at the end

    DB::beginTransaction();//did this
    $customerInfo = CustomerInfo::where('machine_name',$username)->firstOrFail();
    $result = $customerInfo->update($data);
    DB::Commit() //forgot to implement this part.