我创建了laravel软件包,并在其他项目中需要我的软件包。在项目模型中使用软件包特征。但是我得到这个错误=>找不到特质

时间:2019-11-05 12:56:57

标签: php laravel laravel-5 composer-php packagist

我创建了laravel软件包,并在其他项目中需要我的软件包。我在项目模型中使用了软件包特征。

但是我收到此错误=>

  

Symfony \ Component \ Debug \ Exception \ FatalErrorException:特性   找不到“ Encryption \ Src \ Encryptable”

我加载了github包,您可以看到此链接=>

  

https://github.com/kablanfatih/encryption

{
    "name": "kablanfatih/encryption",
    "description": "A package for automatically encrypting and decrypting Eloquent attributes in Laravel , based on configuration settings.",
    "type": "library",
    "license": "MIT",
    "authors": [
        {
            "name": "kablanfatih",
            "email": "kablanfatih34@gmail.com"
        }
    ],
    "minimum-stability": "dev",
    "require": {},
    "autoload": {
        "psr-4": {
            "kablanfatih\\encryption\\": "../encryption"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "kablanfatih\\encryption\\": "../encryption/",
            "Tests\\": "tests"
        }
    },
    "extra": {
        "laravel": {
            "providers": [
                "Barryvdh\\Debugbar\\ServiceProvider"
            ],
            "aliases": {
                "Debugbar": "Barryvdh\\Debugbar\\Facade"
            }
        }
    },
    "require-dev": {
        "barryvdh/laravel-debugbar": "^3.2@dev"
    }
}

<?php

namespace App\Models;

use Encryption\Src\Encryptable;
use Illuminate\Database\Eloquent\Model;

class Question extends Model
{
    use Encryptable;
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'questions';

    /**
     * The attributes that are mass assignable.
     * @var array
     */
    protected $fillable = [
        'question', 'incorrect1', 'incorrect2', 'incorrect3', 'incorrect4', 'correct'
    ];

    /**
     * The attributes that are encrypted.
     *
     * @var array
     */
    protected $encrypted = [
        'question'
    ];
}

1 个答案:

答案 0 :(得分:1)

您的命名空间不正确。 您应该将unique_ptr<Queue_entry>中的"kablanfatih\\encryption\\"替换为Encryption\\