You can check a whether a column exists or not by
if(Schema::hasColumn('users', 'email')) ; //check whether users table has email column
{
//your logic
}
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'm using laravel's awesome validation classes, but I need to know if a column exists in the table (not a row in a given column, the column itself)
Is there a quick/easy way to check this without having to write a custom validation rule? If not, how could I write a validation rule for that?
Thanks
You can check a whether a column exists or not by
if(Schema::hasColumn('users', 'email')) ; //check whether users table has email column
{
//your logic
}
Please or to participate in this conversation.