Не могу понять, почему CRUD пытается сохранить двоичный файл изображения в базе данных вместо имени загруженного файла.
Модель
public function setImageAttribute($value)
{
$attribute_name = "image_wheel";
$disk = "wheel";
$destination_path = "wheel_png";
// if the image was erased
if ($value==null) {
// delete the image from disk
\Storage::disk($disk_wheel)->delete($this->{$image_wheel});
\Storage::disk($disk_vehicle)->delete($this->{$image_vehicle});
// set null in the database column
$this->attributes[$image_wheel] = null;
$this->attributes[$image_vehicle] = null;
}
// if a base64 was sent, store it in the db
if (starts_with($value, 'data:image'))
{
// 0. Make the image
$image = \Image::make($value);
// 1. Generate a filename.
$filename = md5($value.time()).'.jpg';
// 2. Store the image on disk.
\Storage::disk($disk)->put($destination_path.'/'.$filename, $image->stream());
// 3. Save the path to the database
$this->attributes[$attribute_name] = $destination_path.'/'.$filename;
}
}
Сообщение об ошибке
Далее Illuminate \ Database \ QueryException: SQLSTATE [22001]: строковые данные, усеченные справа: 1406 Данные слишком длинные для столбца 'image_wheel' в строке 1 (SQL: вставить в
wheels
(name
,part_no
,alias
,series_id
,sizes
,image_wheel
,image_vehicle
,description
,order
,status
,featured
,-wheel_image_id
,-wheel_tags
,updated_at
,created_at
) значения (,,,,, данные: изображение / JPEG; base64, / 9J / 4AAQSkZJRgABAQAAAQABAAD / 2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD / ...........
image_wheel
поля - person lagbox   schedule 02.12.2017