Learn or Die

生涯勉強。Macです。

クエリビルダーやEloquentを使ったupdateの戻り値

使用サンプル

<?php

//Customerテーブル更新
$result_update = Customer::where([
    'no'        => $this->ary_customer['customerNo'],
    'del_flg'   => 0
])
    ->first()
    ->update([
        'password'      => $ary_request['newpass'],
        'edit_date'     => Carbon::now()
    ]);

//->first()を付けることで  、更新成否で条件分岐ができる
if($result_update){
    echo '更新成功!';
}

参考サイト

kannokanno.hatenablog.com