Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

renan873's avatar

Problems with Laravel 5.7 and PostgreSQL

Running Laravel 5.7, when saving a record, other than users, the field gets filled with spaces until is full, like I want to create a new driver:

$driver = new Driver; $driver->name = "Jhon Smith"; $driver->save();

echo $driver->name; // it saves "Jhon Smith(fill with spaces that the forum don't show) "

This only happens when I use PostgreSQL, I tried differents versions and use it on Windows and Linux, same result.

But when I use MySQL it works fine, this is only with PostgreSQL.

Please help me with this issue and thank for your time.

0 likes
4 replies
jlrdw's avatar

You show it saving correctly above, I don't follow.

Are you saying it is saving John Smith space space space space space space space space space space, etc.

Check with PostgreSQL Docs and see if that's normal behavior , it don't sound right.

You could use trim temporarily until you find out why.

renan873's avatar

@JLRDW - Sorry, I don't read it after post it, it looks like the forum removes excesive spaces, just edited to make it clear.

The problem is that users records don't have this problem, it's only in the other models, so I don't think it's something with postgreSQL

And I worked in other projects with Laravel 5.5 in the same machine using Postgres and it works fine

renan873's avatar

@JLRDW - Thanks, its something with the field type, I use Migrate and in MySQL it makes it Varchar but in Postgres it makes character, thanks for all

And I search for it a lot, but is not laravel is mi migration files

Thanks for the tip

Please or to participate in this conversation.