I use Laravel 7 with Corcel to connect to the database of a WordPress installation.
The connection works fine, no problems fetching data from WordPress so far:
In my WordPress installation there are additional tables used by a project management plugin called WP Project Manager. I want to form a many-to-many relationship between a wordpress table (WP: users) and a plugin table (WP-Plugin: pm_projects) via a pivot table (WP-Plugin: pm_role_user).
The plugin's pivot table has four fields: project_id, role_id, assigned_by and user_id. It connects the users with the projects.
So I created the models Project and Tester (in my context a User is regarded to be a Tester) like this:
use Corcel\Model as Model;
class Project extends Model
protected $table = 'pm_projects';
protected $fillable = [
protected $dates = [
public function testers()
return $this->belongsToMany(Tester::class, 'pm_role_project_users', 'role_project_id', 'user_id');
use Corcel\Model\User as User;
class Tester extends User
public function projects()
return $this->belongsToMany(Project::class, 'pm_role_project_users', 'user_id', 'role_project_id');
When I try to get a users projects with App\Project::where('id',3)->testers()->get();, I get the following error message:
BadMethodCallException with message 'Call to undefined method Illuminate/Database/Eloquent/Builder::testers()'
How can I make many-to-many connections between my WordPress tables in Laravel, using Corcel?