Closed ZedanLab closed 8 years ago
e.g.
$category = Category::findOrFail(8); dd($category);
0 => "name" 1 => "name_ar" 2 => "description" 3 => "description_ar" 4 => "image" 5 => "parent_id" ]
+incrementing: true +timestamps: true
0 => "*" ]
+exists: false +wasRecentlyCreated: false
} `
I think the __call method in NestableTrait that are causing the problem.
please help me @atayahmet
Hello again @atayahmet It has been fixed. But I got new problem with relations methods, and again __call method causing the problem.
Category model: ` <?php
namespace Modules\Arinashop\Entities;
use Cviebrock\EloquentSluggable\Sluggable; use Cviebrock\EloquentSluggable\SluggableScopeHelpers; use Illuminate\Database\Eloquent\Model; use Nestable\NestableTrait;
class Category extends Model { use Sluggable; use SluggableScopeHelpers; use NestableTrait;
protected $parent = 'parent_id';
/**
* Return the sluggable configuration array for this model.
*
* @return array
*/
public function sluggable() {
return [
'slug' => [
'source' => ['name', 'parentName.name'],
],
];
}
protected $table = 'categories';
protected $fillable = ['name', 'name_ar', 'description', 'description_ar', 'image', 'parent_id'];
public function parentName() {
return $this->belongsTo('Modules\Arinashop\Entities\Category', 'parent_id');
}
public function children() {
return $this->hasMany('Modules\Arinashop\Entities\Category', 'parent_id');
}
public function products() {
return $this->hasMany('Modules\Arinashop\Entities\Product', 'category_id', 'id');
}
public function tags() {
$products = $this->hasMany('Modules\Arinashop\Entities\Product', 'category_id', 'id')->get();
$tags = array();
foreach ($products as $product) {
foreach ($product->tags as $tag) {
$tags[] = $tag;
}
}
return $tags;
}
}
`
Problem is when I call any relations methods such as products() or children() after update package, these methods return all items from all categories. And again when I comment __call function it's works.
Hello @muhammed
This package is not designed with use relations. You can use helper or macro way as alternative without NestableTrait.
Please check the docs.
@atayahmet Ok I got it.. Thanks alot my friend :+1:
Hello @atayahmet I've just installed your package to handle categories, but when I use Nestable\NestableTrait all Eloquent methods are not working as where(), findOrFail(), delete() .... And if I remove NestableTrait everything working good.
Any solutions please ..