class BelongsToRelationship (View source)

Properties

protected Factory|Model $factory

The related factory instance.

protected string $relationship

The relationship name.

protected mixed $resolved

The cached, resolved parent instance ID.

Methods

void
__construct(Factory|Model $factory, string $relationship)

Create a new "belongs to" relationship definition.

array
attributesFor(Model $model)

Get the parent model attributes and resolvers for the given child model.

resolver(string|null $key)

Get the deferred resolver for this relationship's parent ID.

Details

void __construct(Factory|Model $factory, string $relationship)

Create a new "belongs to" relationship definition.

Parameters

Factory|Model $factory
string $relationship

Return Value

void

array attributesFor(Model $model)

Get the parent model attributes and resolvers for the given child model.

Parameters

Model $model

Return Value

array

protected Closure resolver(string|null $key)

Get the deferred resolver for this relationship's parent ID.

Parameters

string|null $key

Return Value

Closure

Laravel Cloud is the best place to deploy Laravel, Nuxt, Express, Hono, Node.js, Bun, Go, Flask, Python, and more, with dedicated infrastructure available on AWS through Laravel Private Cloud.