W
W
WebDev2016-11-17 16:28:22
Laravel
WebDev, 2016-11-17 16:28:22

Why is laravel not saving the record?

I parse the api and add it to the database. Accidentally discovered that one of the records is not recorded.

echo $post->text . PHP_EOL;
$created = Post::create([
    'text' => $post->text
]);
echo $created->text;

Here is the code that outputs the string to be written, and then saves to the database and displays the field from the newly created record in the database.
This code displays everything correctly, as if the record has passed, but after checking this record in the database, the field is empty.
Field of type TEXT, line for writing is 'h ttps://twitter.com/thatgirlbishop/status/799115312037646336/photo/1'
UPD: At the beginning of the line there is a smiley, because of which everything seems to be hidden.
UPD3: Does not write to the database because of the smiley. I can't insert the smiley face too. Here is a screenshot f8ab16a36cc2411c88678c1f441bcc6a.png
How to insert such a record?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
A
Alexander, 2016-11-17
@kentuck1213

Check the Model, maybe there is no field specified in the $fillable property.

I
Ilya, 2016-11-18
Hrebet @hrebet

Try using comparison for the storage field of such information - utf8mb4_general_ci .

V
Vyacheslav Plisko, 2016-11-17
@AmdY

Check the encoding and set the appropriate one for the database or overtake it through iconv

V
Vic Shostak, 2016-11-17
@vikkyshostak

Replace the emoticon with its emoji code (or html) and that's it.

M
Mokhirjon Naimov, 2016-11-19
@zvermafia

Ilya Khrebet gave a good answer, but if there are problems with transcoding, then you can simply save it in JSON format ( json_encode()/ json_decode())

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question