朋友,收到错误消息sqlstate 42s22 column
activity_post_comments not found 1054 unknown column in 'field list'
但是此列名称存在于我的数据库中。
我已经检查了我的数据库,并且检查了拼写错误,但是我仍然收到此错误
public function storecomments(Request $request, $id)
{
// Create Comment
$activity_post = new ActivityPost;
$activity_post->activity_post_comments = $request->input('activity_post_comments');
$activity_post->activity_post_id = $id;
$activity_post->user_id = auth()->user()->id;
$activity_post->save();
return redirect()->back()->with('success', 'Comment Added');
}
不确定为什么会收到此错误,所以我无法将这些值保存在数据库中
型号:
class ActivityPostComment extends Model
{
use SoftDeletes;
// Table Name
protected $table = 'activity_post_comments';
// Primary Key
public $primaryKey = 'id';
// Timestamps
public $timestamps = true;
/**
* The attributes that should be mutated to dates.
*
* @var array
*/
protected $dates = ['deleted_at'];
public function post(){
return $this->belongsTo('App\ActivityPost');
}
}
答案 0 :(得分:1)
按照您发布的上述代码。您称呼错误的模型的模型类名称为
ActivityPostComment
使用时
ActivityPost