BelongsToMany
in package
Defines a belongs-to-many relationship (many-to-many).
Example: A Post belongs to many Categories
Attributes
- #[Attribute]
- \Attribute::TARGET_PROPERTY
Table of Contents
Properties
- $dependent : DependentStrategy|null
- $foreignPivotKey : string|null
- $parentKey : string|null
- $pivotTable : string|null
- $relatedKey : string|null
- $relatedModel : string
- $relatedPivotKey : string|null
Methods
- __construct() : mixed
- Constructor
Properties
$dependent read-only
public
DependentStrategy|null
$dependent
= null
$foreignPivotKey read-only
public
string|null
$foreignPivotKey
= null
$parentKey read-only
public
string|null
$parentKey
= 'id'
$pivotTable read-only
public
string|null
$pivotTable
= null
$relatedKey read-only
public
string|null
$relatedKey
= 'id'
$relatedModel read-only
public
string
$relatedModel
$relatedPivotKey read-only
public
string|null
$relatedPivotKey
= null
Methods
__construct()
Constructor
public
__construct(string $relatedModel[, string|null $pivotTable = null ][, string|null $foreignPivotKey = null ][, string|null $relatedPivotKey = null ][, string|null $parentKey = 'id' ][, string|null $relatedKey = 'id' ][, DependentStrategy|null $dependent = null ]) : mixed
Parameters
- $relatedModel : string
-
The fully qualified class name of the related model
- $pivotTable : string|null = null
-
The pivot/junction table name
- $foreignPivotKey : string|null = null
-
The foreign key in pivot table for this model
- $relatedPivotKey : string|null = null
-
The foreign key in pivot table for related model
- $parentKey : string|null = 'id'
-
The parent key column name (default: id)
- $relatedKey : string|null = 'id'
-
The related key column name (default: id)
- $dependent : DependentStrategy|null = null
-
Cascade behavior when parent is destroyed