I'm getting an error when saving some empty text, textarea fields. Laravel forms this sql query:
SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'inside_area' at row 1 (SQL: insert into `ads` (`street`, `quarter`, `building_number`, `inside_area`, `price`, `admin_comment`, `valid_to`, `price_heating`, `rooms`, `floor_number`, `floors_number`, `kitchen_area`, `years`, `public_comment`, `video_url`, `3d_url`, `user_id`, `updated_at`, `created_at`) values (, , , , , , , , , , , , , , , , 1, 2017-03-13 14:33:50, 2017-03-13 14:33:50))
P.S. db table was created not in laravel way - I'm using existing tables, this may be important.
UPDATED: problem are only with INT fields, if they has empty form field on saving!
Table:
CREATE TABLE `ads` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`user_id` int(11) DEFAULT NULL,
`ad_type_id` int(11) DEFAULT NULL,
`city_id` int(11) DEFAULT NULL,
`street` varchar(255) DEFAULT NULL,
`quarter` varchar(255) DEFAULT NULL,
`building_number` varchar(255) DEFAULT NULL,
`inside_area` int(11) DEFAULT NULL,
`price` int(11) DEFAULT NULL,
`show_price_per_meter` int(1) DEFAULT NULL,
`price_heating` int(10) DEFAULT NULL,
`admin_comment` text,
`valid_to` datetime DEFAULT NULL,
`rooms` int(11) DEFAULT NULL,
`floor_number` int(11) DEFAULT NULL,
`floors_number` int(11) DEFAULT NULL,
`kitchen_area` int(11) DEFAULT NULL,
`balcony` int(1) DEFAULT NULL,
`balcony_glazed` int(1) DEFAULT NULL,
`years` int(11) DEFAULT NULL,
`dyn_house_type_id` int(11) DEFAULT NULL,
`dyn_heating_id` int(11) DEFAULT NULL,
`dyn_installation_ids` int(11) DEFAULT NULL,
`public_comment` text,
`video_url` varchar(11) DEFAULT NULL,
`3d_url` varchar(11) DEFAULT NULL,
`available_for_trade` int(1) DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
FORM:
{!! Form::open(['url'=>'ads']) !!}
{!! Form::number('inside_area', null, ['class'=>'form-control']) !!}
{!! Form::close() !!}
Route:
Route::resource('ads', 'AdsController');
Save action:
public function store() {
$input = Request::all();
\App\Ad::create($input);
return redirect('/ads/my_index');
}
P.S.2 If I provide any value to inside_area
field, it goes ok and the next error is for price
field.
via Gediminas