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'];
}
https://www.cnblogs.com/y734290209/p/11330319.html
这里有一个相同问题: 请查看是否对问题有帮助~
https://ask.csdn.net/questions/1094883