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

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'slug' in 'where clause' (SQL: select count(*) as aggregate from users where slug = test12345 and users.deleted_at is null) #386

Open
nakamotojp opened this issue Sep 21, 2022 · 2 comments

Comments

@nakamotojp
Copy link

  1. I install new LavaLite, and create new User from FOO.com/user/register, then I have error [SQLSTATE[42S22]: Column not found: 1054 Unknown column 'slug' in 'where clause' (SQL: select count(*) as aggregate from userswhereslug= test12345 andusers.deleted_at is null)](https://FOO.ap-northeast-1.amazonaws.com/user/register#top)

image
image
image

  1. so I make slug in users table, and create new User, then I have error Class "App\Http\Controllers\Auth\Role" not found

image

image

  1. of caurse , I already migrated, and composer updated.

image

@nakamotojp
Copy link
Author

nakamotojp commented Sep 21, 2022

class Role{}

  1. /lavalite/app/Facades/Role.php
  2. /lavalite/app/Forms/Role.php
  3. /lavalite/app/Litepie/Role.php
  4. /lavalite/app/Models/Role.php
  5. /lavalite/vendor/lavalite/framework/src/Litepie/Roles/Forms/Role.php
  6. /lavalite/vendor/lavalite/framework/src/Litepie/Roles/Models/Role.php

function findBySlug{}

  1. /lavalite/vendor/lavalite/framework/src/Litepie/Database/Traits/Sluggable.php
    public static function findBySlug($slug, $columns = ['*'])
    {
        return self::whereSlug($slug)->first($columns);
    }
  1. /lavalite/vendor/lavalite/framework/src/Litepie/Repository/Eloquent/BaseRepository.php
    public function findBySlug($value = null, $columns = ['*'])
    {
        $this->applyCriteria();
        $this->applyScope();
        $model = $this->model->whereSlug($value)->first($columns);
        $this->resetModel();

        return $this->parserResult($model);
    }

function attachRole

  1. /lavalite/vendor/lavalite/framework/src/Litepie/Roles/Models/Role.php
    public function attachRoles($user)
    {
        $guard = $this->getGuardRoute();
        $roles = config('auth.register.roles.' . $guard, null);

        if ($roles == null) {
            return;
        }

        foreach ($roles as $role) {
            $roleId = Role::findBySlug($role)->id;
            $user->attachRole($roleId);
        }

        return true;
    }
  1. /lavalite/vendor/lavalite/framework/src/Litepie/Roles/Interfaces/HasRoleAndPermission.php
    public function attachRole($role);

/lavalite/vendor/lavalite/framework/src/Litepie/Roles/Models/Role.php

class Role extends Model implements RoleHasRelationsContract
{
    use Filer;
    use Hashids;
    use Sluggable;
    use PresentableTrait;
    use RoleHasRelations;

if I add use Litepie\Roles\Models\Role; in /lavalite/app/Http/Controllers/Auth/RegisterController.php

there are Call to undefined method App\Models\User::notify() , Because I am not logged in.

image

@nakamotojp
Copy link
Author

Breeze Wouldn't you use it?

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

2 participants
@nakamotojp and others