ideas icon indicating copy to clipboard operation
ideas copied to clipboard

Support for first_name last_name instead of name when searching for an Eloquent User.

Open jeverington opened this issue 3 years ago • 2 comments

Statamic supports first_name and last_name for a signup, etc, but it's not when searching for users. I am using Statamic with users in a database.

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'name' in 'where clause' (SQL: select count(*) as aggregate from users where (email like %dsdd% or name like %dsdd%) and users.deleted_at is null)

jeverington avatar Jun 16 '22 13:06 jeverington

I get around this by making a 'name' column with a trigger that concatenates both first_name and last_name

ryanmitchell avatar Jun 20 '22 06:06 ryanmitchell

ALTER TABLE 'users' ADD COLUMN 'name' varchar(255) AS (CONCAT(first_name,' ',last_name)) STORED AFTER last_name;

Seems to work fine, but would be good to have native support

jeverington avatar Jun 24 '22 12:06 jeverington

I'm unable to reproduce this issue on the latest version of Statamic. I can search by first_name and last_name columns just fine, as long as the fields exist in my user blueprint.

I'm going to close this issue now. If you're still experiencing this issue, please leave a comment and we can re-open the issue. Thanks!

duncanmcclean avatar Mar 13 '24 15:03 duncanmcclean