Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class name must be a valid object or a string.. #14

Closed
ZedanLab opened this issue Aug 11, 2016 · 7 comments
Closed

Class name must be a valid object or a string.. #14

ZedanLab opened this issue Aug 11, 2016 · 7 comments

Comments

@ZedanLab
Copy link

hello..

am just use your package now.. and when i trying to
php artisan laratrust:migration
I got this error:
`[2016-08-11 14:10:25] local.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: Class name must be a valid object or a string in C:\xampp\htdocs\enngezshirt\vendor\santigarcor\laratrust\src\commands\MigrationCommand.php:109
Stack trace:
#0 C:\xampp\htdocs\enngezshirt\vendor\santigarcor\laratrust\src\commands\MigrationCommand.php(83): Laratrust\MigrationCommand->createMigration('roles', 'role_user', 'permissions', 'permission_role')
#1 [internal function]: Laratrust\MigrationCommand->fire()
#2 C:\xampp\htdocs\enngezshirt\vendor\laravel\framework\src\Illuminate\Container\Container.php(507): call_user_func_array(Array, Array)
#3 C:\xampp\htdocs\enngezshirt\vendor\laravel\framework\src\Illuminate\Console\Command.php(169): Illuminate\Container\Container->call(Array)
#4 C:\xampp\htdocs\enngezshirt\vendor\symfony\console\Command\Command.php(256): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 C:\xampp\htdocs\enngezshirt\vendor\laravel\framework\src\Illuminate\Console\Command.php(155): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 C:\xampp\htdocs\enngezshirt\vendor\symfony\console\Application.php(794): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#7 C:\xampp\htdocs\enngezshirt\vendor\symfony\console\Application.php(186): Symfony\Component\Console\Application->doRunCommand(Object(Laratrust\MigrationCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 C:\xampp\htdocs\enngezshirt\vendor\symfony\console\Application.php(117): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 C:\xampp\htdocs\enngezshirt\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php(107): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 C:\xampp\htdocs\enngezshirt\artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 {main}

`
@santigarcor

@KKSzymanowski
Copy link
Collaborator

KKSzymanowski commented Aug 11, 2016

How does your config/auth.php look like?

We look in config/auth.php for providers.users.model which defaults to App\User::class

@ZedanLab
Copy link
Author

@KKSzymanowski i am using multiple auth.

auth.php:

`<?php

return [

/*
|--------------------------------------------------------------------------
| Authentication Defaults
|--------------------------------------------------------------------------
|
| This option controls the default authentication "guard" and password
| reset options for your application. You may change these defaults
| as required, but they're a perfect start for most applications.
|
 */

'defaults'  => [
    'guard'     => 'customer',
    'passwords' => 'customers',
],

/*
|--------------------------------------------------------------------------
| Authentication Guards
|--------------------------------------------------------------------------
|
| Next, you may define every authentication guard for your application.
| Of course, a great default configuration has been defined for you
| here which uses session storage and the Eloquent user provider.
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| Supported: "session", "token"
|
 */

'guards'    => [
    'customer' => [
        'driver'   => 'session',
        'provider' => 'customers',
    ],
    'admin'    => [
        'driver'   => 'session',
        'provider' => 'admins',
    ],

    'api'      => [
        'driver'   => 'token',
        'provider' => 'customers',
    ],
],

/*
|--------------------------------------------------------------------------
| User Providers
|--------------------------------------------------------------------------
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| If you have multiple user tables or models you may configure multiple
| sources which represent each model / table. These sources may then
| be assigned to any extra authentication guards you have defined.
|
| Supported: "database", "eloquent"
|
 */

'providers' => [
    'admins'    => [
        'driver' => 'eloquent',
        'model'  => App\Admin::class,
    ],
    'customers' => [
        'driver' => 'eloquent',
        'model'  => App\Customer::class,
    ],

    // 'users' => [
    //     'driver' => 'database',
    //     'table' => 'users',
    // ],
],

/*
|--------------------------------------------------------------------------
| Resetting Passwords
|--------------------------------------------------------------------------
|
| Here you may set the options for resetting passwords including the view
| that is your password reset e-mail. You may also set the name of the
| table that maintains all of the reset tokens for your application.
|
| You may specify multiple password reset configurations if you have more
| than one user table or model in the application and you want to have
| separate password reset settings based on the specific user types.
|
| The expire time is the number of minutes that the reset token should be
| considered valid. This security feature keeps tokens short-lived so
| they have less time to be guessed. You may change this as needed.
|
 */

'passwords' => [
    'customers' => [
        'provider' => 'customers',
        'email'    => 'auth.emails.password',
        'table'    => 'password_resets',
        'expire'   => 60,
    ],
],

];
`

@KKSzymanowski
Copy link
Collaborator

If I understand correctly, you commented users section because you have two completely different groups of users which you called admins and customers. Am I right?

Do you want to assign roles to one of those groups or to both of them? How does your user-role-permission structure will look like?

I think something may be wrong with your approach. If you want to divide users into two groups and that's it, you don't need this package. If you want to assing roles to users that belong to one of these groups you need to specify which one by doing:

'users'    => [
    'driver' => 'eloquent',
    'model'  => App\Admin::class,
],

or

'users' => [
    'driver' => 'eloquent',
    'model'  => App\Customer::class,
],

If you want to assing roles to both of the groups, I'm sorry but this package doesn't support that.

Another thing to consider, would be creating one users table and App\User model which will aggregate all users and then you can divide them into groups by assigning specific permissions like administrator or customer.

Does any of this solve your problem?

@ZedanLab
Copy link
Author

Thanks a lot my bro, I just add
'users' => [ 'driver' => 'eloquent', 'model' => App\Admin::class, ],

and it's working..

@erolando
Copy link

me the same error occurs, and not how to fix it.

captura de pantalla 2016-10-09 a las 10 04 24 p m

@santigarcor
Copy link
Owner

@erolando How's your auth.php file? Remember that laratrust uses the users provider in order to make everything work.

@erolando
Copy link

I'm sorry, if you already make the change and it worked correctly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants