【问题标题】:Laravel ACL Errors in Console Call to undefined method Illuminate\Foundation\Application::where()控制台调用未定义方法 Illuminate\Foundation\Application::where() 中的 Laravel ACL 错误
【发布时间】:2023-04-01 07:23:01
【问题描述】:

我目前是 Laravel 的新手,正在努力学习它。我现在用它工作了很多小时,并尝试从https://github.com/mateusjunges/laravel-acl 安装和使用 Laravel ACL 但我不断收到错误。

我的步骤:

  1. 已安装
  2. 试过php artisan migrate -> 没用 -> Nothing to migrate.
  3. 手动尝试->将迁移文件从vendor>mateusjunges>laravel-acl>database>migrations>复制到..database>migrations
  4. 再次php artisan migrate -> 工作
  5. 试过php artisan permission:create testperm testperm "test"->错误

错误:

    Call to undefined method Illuminate\Foundation\Application::where()

  at testproject\vendor\mateusjunges\laravel-acl\src\Console\Commands\CreatePermission.php:43
     39▕     public function handle()
     40▕     {
     41▕         $permissionModel = app(config('acl.models.permission'));
     42▕
  ➜  43▕         $permission = $permissionModel->where('slug', $this->argument('slug'))
     44▕             ->orWhere('name', $this->argument('name'))
     45▕             ->first();
     46▕
     47▕         if (! is_null($permission)) {

  1   testproject\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:36
      Junges\ACL\Console\Commands\CreatePermission::handle()

  2   testproject\vendor\laravel\framework\src\Illuminate\Container\Util.php:40
      Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
  1. 试过php artisan user:permissions 1 -> 下一个错误

错误:

Call to undefined method Illuminate\Foundation\Application::find()

  at testproject\vendor\mateusjunges\laravel-acl\src\Console\Commands\UserPermissions.php:44
     40▕         $userParameter = $this->argument('user');
     41▕         $userModel = app(config('acl.models.user'));
     42▕
     43▕         if (is_numeric($userParameter)) {
  ➜  44▕             $user = $userModel->find((int) $userParameter);
     45▕         } elseif (is_string($userParameter)) {
     46▕             $table = config('acl.tables.users');
     47▕             $columns = $this->verifyColumns($table);
     48▕

  1   testproject\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:36
      Junges\ACL\Console\Commands\UserPermissions::handle()

  2   testproject\vendor\laravel\framework\src\Illuminate\Container\Util.php:40
      Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()

不知道自己做错了什么,安装成功了……

【问题讨论】:

    标签: php laravel laravel-8 acl


    【解决方案1】:

    你必须看包的文档,如果你自己尝试总是很难的......

    这是documentation,它清楚地写着:要安装运行php artisan acl:install,然后你还有一个可以添加你缺少的所有需要​​的文件(这就是错误的原因)php artisan vendor:publish --provider="Junges\ACL\Providers\ACLServiceProvider" --tag="acl-migrations"...

    请阅读文档...

    【讨论】:

    • sry 应该指定安装部分,使用 php artisan acl:install 安装它,对于带有 vendor:publish 的部分,我收到消息:找不到路径:D:\test\testproject\vendor \mateusjunges\laravel-acl\src\Providers/database/migrations> 关注文档并关注 yt 上的一些视频..
    • 我不确定您在 Windows 中运行它是否存在问题。我认为它应该可以工作...如果您手动转到D:\test\testproject\vendor\mateusjunges\laravel-acl\src`, do you see Provider` 和更多文件夹?另外,如果有Providers,你看到Providers/database/migrations了吗?
    • 这是下一个问题......Providers 中没有文件夹,只有 3 个文件:ACLAuthServiceProvider.phpACLEventsServiceProvider.phpACLServiceProvider.php
    • 好的,只有这3个文件是可以的,就像你看到source code一样,你可以看到这些文件。看到这个source code,这个正在执行并给你错误,config('acl.custom_migrations') 的值是多少?尝试在 tinker 中运行它并在此处分享值。
    • 你的意思是在php artisan tinker 中运行config('acl.custom_migrations') ?如果是这样,我得到=> null
    猜你喜欢
    • 2018-06-25
    • 1970-01-01
    • 2017-08-24
    • 2015-09-23
    • 2014-04-17
    • 1970-01-01
    • 2016-04-17
    • 1970-01-01
    • 2016-04-21
    相关资源
    最近更新 更多