I have table items(means artefacts).And artefacts (not all of them) can be created using another (one or more) artefact(s).
I can't find any working example in google how to do many to many self relation in laravel.
I wrote something like this:
class Item extends Model
{
public function items()
{
return $this->belongsToMany('App\Item', 'item_id');
}
public function components()
{
return $this->belongsToMany('App\Item', 'component_id');
}
}
But I have no idea what to do next.I stuck.Any help would be appreciated.
Here my table structure:
id | name | price | extra_item_slot
------------------------------------
But I can change it if need.For add another column or something like that.
Upd: One Artefact can contain multiple child Artefacts.