Schema::create('category_product', function (Blueprint $table) {
$table->foreignId('product_id')->constrained('products')->cascadeOnDelete();
$table->foreignId('category_id')->constrained('categories')->cascadeOnDelete();
});public function categories()
{
return $this->belongsToMany(Category::class, 'category_product');
}
Section::make('meta')->schema([
FileUpload::make('thumbnail')->disk('products'),
SelectTree::make('categories')
->relationship('categories', 'name', 'parent_id'),
Checkbox::make('is_active'),
])->columnSpan(1),