Files
CKB/app/Models/ProductCategory.php

27 lines
616 B
PHP
Executable File

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class ProductCategory extends Model
{
use HasFactory, SoftDeletes;
protected $fillable = ['name','parent_id'];
public function products(){
return $this->hasMany(Product::class, 'product_category_id');
}
public function parent(){
return $this->belongsTo(ProductCategory::class, 'parent_id');
}
public function children(){
return $this->hasMany(ProductCategory::class,'parent_id');
}
}