I have a table named categories
and here is it's structure:
id bigint(20) AUTO_INCREMENT
name varchar(255)
description varchar(255)
short_name varchar(255)
picture varchar(255)
parent_category int(11)
category_type tinyint(4)
So each category has a category_type
which can be one of these values:
1: Main Category
2: Superior Category
3: Secondary Category
4: Secondary Sub Category
Now I wanted to set a One To Many relationship between these categories.
For example: a main category has many superior categories and a superior category is related to one main category.
And this will apply to the rest of them as well.
But because I have only one Model which is Category
, I don't know how to apply this relationship, so if you know, plz help me out...
Model Category.php
:
class Category extends Model
{
use HasFactory;
protected $fillable = ['name','short_name','description','picture','category_type','parent_category'];
}