본문 바로가기
이과/laravel 자료

[LARAVEL] Column not found: 1054 Unknown column 에러

by 코딩초밥 2022. 9. 1.
반응형

CONTROLLER 

 ProductModel::where('id',$id)->update([
'name' => $request->name,
'r_name' => $request->r_name,
'asset_group_id' => $request->asset_group_id
]);

return redirect(route('product.index'));

계속 있는 필드인데도..

없다고 나온다.

 

BLADE

<form
action="{{ route('productmodify.update',$output->id) }}"
method="POST"
enctype="multipart/form-data"
@csrf
@method('PATCH')

<div class="mb-3 row">
<label  class="col-sm-33 col-form-label" style="font-weight: normal; color: #869ac0;">에셋파일 : </label>
<div class="col-sm-10 " style="display: flex; flex-direction: row;" >
<input type="text" name="name"  class="form-control" value="{{ $output->name }}"  style="color: #869ac0;  border: 1px solid #99999; background-color: transparent; width:30%;"><i class="fas fa-pencil-alt fa-lg fa-fw" style="color: rgb(180, 180, 180);padding-left:10px;padding-top: 18px"></i></input>

</div>
</div>

 

ERROR

 

 

[해결방법]

모델수정 전

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class ProductModel extends Model
{
    use HasFactory;
    
    protected $table = 'vcms_assets';
    

}

모델 수정 후

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class ProductModel extends Model
{
    use HasFactory;
    public $timestamps = false;
    protected $table = 'vcms_assets';
    protected $fillable = ['name', 'r_name', 'asset_group_id'];

}
반응형

댓글