Answer the question
In order to leave comments, you need to log in
Why is there an error when creating a post?
Illuminate\Database\QueryException
SQLSTATE[HY000]: General error: 1364 Field 'countrie' doesn't have a default value (SQL: insert into `post` (`category`, `name`, `description`, `updated_at`, `created_at`) values (category, name, description, 2020-01-22 15:56:31, 2020-01-22 15:56:31))
Here comes such a terrible error. Most likely, I am sending some value to the database that it does not want to accept, but I don’t know which one it is swearing at.
What does my schema look like?
Schema::create('post', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string("name", 255);
$table->text("description");
$table->text("img")->nullable();
$table->text("category");
$table->text("countrie");
$table->text("city_id");
$table->text("address");
$table->text("price");
$table->timestamps();
});
protected $table ='post';
protected $fillable =[
'name',
'city_id',
'address',
'price',
'category',
'description'
];
public function create(Request $request){
$objPost = new Post();
$objPost = $objPost::create([
'category'=>'category',
'name'=> 'name',
'description'=>'description'
]);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question