-2

In my project a user can comment on posts and images, but when a user comments emojis, it turns to '?' (question mark). Can someone help me with this issue .

'mysql' => [
            'driver' => 'mysql',
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'prefix_indexes' => true,
            // 'strict' => true,
            'strict' => false,
            'engine' => null,
            'options' => extension_loaded('pdo_mysql') ? array_filter([
                PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
            ]) : [],
        ],

Akil Patel
  • 145
  • 2
  • 13
  • 1
    (Your question does not contain any useful information based on which we could actually help you here, so start by checking the mentioned question. And please go read [ask], and add details to your question, if you still need help.) – 04FS Jan 28 '20 at 08:11

1 Answers1

0

Make sure you have the charset and collation correctly set up in the database config file.

// config/database.php

'mysql' => [
    'driver' => 'mysql',
    'host' => env('DB_HOST', 'localhost'),
    'port' => env('DB_PORT', '3306'),
    'database' => env('DB_DATABASE', ''),
    'username' => env('DB_USERNAME', ''),
    'password' => env('DB_PASSWORD', ''),
    'charset' => 'utf8mb4',
    'collation' => 'utf8mb4_general_ci',
    'prefix' => '',
    'strict' => false,
    'engine' => null,
],

This will let laravel knows what utf8mb4 charset to use when saving

Shashank Shah
  • 2,077
  • 4
  • 22
  • 46