Call to a member function hasPermissionTo() on null code example
Example 1: Call to a member function addEagerConstraints() on null
You are missing return statements in the methods that define relations. They need to return relation definition.
Example 2: Call to a member function connection() on null
I think you just uncomment $app->withFacades();, $app->withEloquent(); lines in bootstrap/app.php;
And check again, it works for me.