Closed hellozach closed 8 years ago
You need to follow the installation instructions nonetheless. Add the UserHasTeamsTrait to your user model and you should be good :)
Zach Johnson notifications@github.com schrieb am Mo., 6. Juni 2016, 6:06 nachm.:
I'm not able to use any of the views without error.
Going to /team returns:
ErrorException in GenericUser.php line 98: Undefined index: teams
I have a feeling the app/Team.php file isn't completed.. Here is my app/Team.php file:
<?php
namespace App;
use Mpociot\Teamwork\TeamworkTeam;
class Team extends TeamworkTeam { // }
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mpociot/teamwork/issues/41, or mute the thread https://github.com/notifications/unsubscribe/AAxHTMDRhO6qZrBgT8dee_uxhj5SQP6uks5qJEVlgaJpZM4IvDjU .
I tried switching UserHasTeams
with UserHasTeamsTrait
but that didn't resolve the issue.
Here is my app/User.php file:
namespace App;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Laravel\Cashier\Billable;
use Mpociot\Teamwork\Traits\UserHasTeams;
class User extends Authenticatable
{
use Billable;
use UserHasTeams;
// ...
}
In your issue you mentioned a class called "GenericUser". Does this user have the trait too? The team class looks good
I believe GenericUser is what Laravel uses for its Authentication package. I added the trait to app/User.php
Feel free to register and go to the teams page: http://io.lefkomedia.com/register http://io.lefkomedia.com/teams
Here is the full error report for /team:
in GenericUser.php line 98
at HandleExceptions->handleError('8', 'Undefined index: teams', '/home/lefko_vps/io.lefkomedia.com/vendor/laravel/framework/src/Illuminate/Auth/GenericUser.php', '98', array('key' => 'teams')) in GenericUser.php line 98
at GenericUser->__get('teams') in TeamController.php line 24
at TeamController->index()
at call_user_func_array(array(object(TeamController), 'index'), array()) in Controller.php line 80
at Controller->callAction('index', array()) in ControllerDispatcher.php line 146
at ControllerDispatcher->call(object(TeamController), object(Route), 'index') in ControllerDispatcher.php line 94
at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Authenticate.php line 28
at Authenticate->handle(object(Request), object(Closure))
at call_user_func_array(array(object(Authenticate), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 96
at ControllerDispatcher->callWithinStack(object(TeamController), object(Route), object(Request), 'index') in ControllerDispatcher.php line 54
at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\Teamwork\TeamController', 'index') in Route.php line 174
at Route->runController(object(Request)) in Route.php line 140
at Route->run(object(Request)) in Router.php line 724
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 64
at VerifyCsrfToken->handle(object(Request), object(Closure))
at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 62
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Router.php line 726
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 699
at Router->dispatchToRoute(object(Request)) in Router.php line 675
at Router->dispatch(object(Request)) in Kernel.php line 246
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 44
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Kernel.php line 132
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 99
at Kernel->handle(object(Request)) in index.php line 54
The TeamController is using auth()->user()->teams
to resolve the teams.
So it seems like your auth()->user()
returns a GenericUser model instead of your user.
How does your config/auth.php
look like?
Thank you!
I switched it over to use the database instead of Eloquent. Once I switched it back and cleared the cache Teamwork worked! (I'm not sure why I changed it - just being naïve I think ha)
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],
I'm not able to use any of the views without error.
Going to /team returns:
I have a feeling the app/Team.php file isn't completed.. Here is my app/Team.php file: