在Rinvex类别中使用Rinvex属性

时间:2018-11-06 12:04:50

标签: laravel laravel-5

在我的项目中,我使用了两个软件包,rinvex/laravel-categoriesrinvex/laravel-attributes

现在我想使categories可以具有属性,但是当我在Category模型中应用 Attribution 特性并尝试保存填充了属性的模型时,它会抛出例外:

  

传递给App \ Model \ Category :: getEntityAttribute()的参数1必须为字符串类型,给定为null,在/ home / vagrant / www / myapp / vendor / laravel / framework / src / Illuminate / Database /中调用第444行的Eloquent / Concerns / HasAttributes.php

类别模型:

<?php

namespace App\Model;

use Rinvex\Attributes\Traits\Attributable;
use Rinvex\Categories\Models\Category as RinvexCategory;

class Category extends RinvexCategory
{
    use Attributable;
}

属性模型

<?php

namespace App\Model;

use Rinvex\Attributes\Models\Attribute as RinvexAttribute;
use Rinvex\Categories\Traits\Categorizable;

class Attribute extends RinvexAttribute
{
    use Categorizable;
}

我的测试用例

$categories = new Category;
$cat = $categories->first();
$cat->attr1 = 'test_string'; // attr1 is valid varchar attribute. Type varchar also is registered in service provider
$cat->save();

有人试图做这样的事情吗?任何帮助表示赞赏。预先感谢。

0 个答案:

没有答案