weixin_48119159 2020-08-22 10:32 采纳率: 0%
浏览 154

laravel-admin更新数据失败

laravel小白,今天使用laravel-admin更新数据时,虽然提示成功,但是数据库里的数据始终没有变化,已经检查过$fillable,添加了字段,然而还是更新不了数据,下面是contrller里面的代码

 protected function formEdit()
    {
        $lessonList = DB::table('lesson')->pluck('lesson_name','id')->toArray();
        $form = new Form(new Contract());

        $form->decimal('receive', __('收款'));
        $form->decimal('refund', __('退款'));
        $form->number('user_id', __('用户id'));
        $form->number('class_hour', __('总课时'));
        $form->number('remaining', __('剩余课时'));
        $form->select('lesson_id',__('课程名称'))->options($lessonList);
        $form->select('pay_type', __('支付方式'))->options($this->pay_type);

        return $form;
    }

    public function edit($id, Content $content)
    {
        return $content
            ->title($this->title())
            ->body($this->formEdit()->edit($id));
    }

下面是model里面的代码

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

/**
 * @property int $id
 * @property float $receive
 * @property float $refund
 * @property int $lesson_id
 * @property int $user_id
 * @property int $class_hour
 * @property int $remaining
 * @property int $venue_id
 * @property int $created_at
 * @property int $updated_at
 * @property int $pay_type
 */
class Contract extends Model
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'contract';

    /**
     * @var array
     */
    protected $fillable = ['receive', 'refund', 'lesson_id', 'user_id', 'class_hour', 'remaining', 'venue_id', 'created_at', 'updated_at','pay_type'];

}
  • 写回答

2条回答 默认 最新

  • dabocaiqq 2020-08-22 16:47
    关注
    评论

报告相同问题?

悬赏问题

  • ¥50 易语言把MYSQL数据库中的数据添加至组合框
  • ¥20 求数据集和代码#有偿答复
  • ¥15 关于下拉菜单选项关联的问题
  • ¥20 java-OJ-健康体检
  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况