Neuron-PHP

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

$foreignPivotKey read-only

public string|null $foreignPivotKey = null

$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


        
On this page

Search results