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

swarley_HIMYM's avatar

Laravel Spatie Roles

i have table users with this field like this name, email, department, roles

 Call to a member function contains() on string (View: /opt/lampp/htdocs/carpool/resources/views/home.blade.php) 

i got some error like this, the error show in all routes, i have reading about the error on internet and solutions is if i remove roles field from my users table the error is gone

why should i do? and i need table field roles to for my api

0 likes
6 replies
Sinnbeck's avatar

Why do you have a roles column on the users table if you plan to use spatie roles?

Sinnbeck's avatar

@swarley_HIMYM You need to make a choice.

  1. Rename that column
  2. Dont use spatie roles
  3. Get your api working with spatie roles

The problem is that you currently have both a column named roles, and a relationship named roles. You cannot have both

Please or to participate in this conversation.