我有一个Model Comment.php和DB上的表注释。
我有一些播种机可以在表中插入数据,还有一些其他的模型和控制器已经在工作了。
问题是,每当我试图创建一个新的评论时,它都是空的。例如:
{
$comment = new Comment([
'description' => $request->input('description'),
'status' => 'active',
'profile_id' => $request->input('profile_id')
]);
return $comment;
}
返回
[]
我确保模型和控制器都存在。我实际上可以索引所有的评论。我也在使用正确的型号:
use App'Comment;
知道我应该在哪里检查吗?或者为什么Laravel/Eloquent在尝试创建新对象时没有识别模型?
编辑:
这是我的型号:
namespace App;
use Illuminate'Database'Eloquent'Model;
class Comment extends Model
{
public $fillable = ['*'];
public function profile(){
$this->belongsTo(Profile::class);
}
public function project(){
$this->belongsTo(Project::class);
}
public function scopeOfProject($query,$projectId){
return $query->where('project_id',$projectId);
}
public $fillable = ['*'];
是问题所在。