SQLSTATE[HY000]: General error: 1364 Field ‘name’ doesn’t have a default value
i am using mysql v5.7 and laravel 5.5 ,, when i am “add product” i am geeting error
SQLSTATE[HY000]: General error: 1364 Field 'name' doesn't have a default value
.
this is my products table
public function up()
{
Schema::create('products', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('description');
$table->string('size');
$table->string('price');
$table->string('image');
$table->timestamps();
});
}
this is my ProductController with store method
public function store(Request $request)
{
// validation
$this->validate($request,[
'name'=> 'required',
'description'=>'required',
'size'=>'required',
'price'=>'required',
'image'=>'image|mimes:png,jpg,jpeg|max:10000'
]);
// image upload
$image=$request->image;
if($image){
$imageName=$image->getClientOriginalName();
$image->move('images',$imageName);
$formInput['image']=$imageName;
}
Product::create($formInput);
return redirect()->route('product.index');
}
.
when i am add ->nullable
method is not error but the data in table phpmyadmin is null / not show to name, description, size, price .
.
please help me…
from Laravel Questions and Answers https://laravelquestions.com/laravel/sqlstatehy000-general-error-1364-field-name-doesnt-have-a-default-value/
via Lzo Media
No comments:
Post a Comment