Blueprint also allows you to define many of the relationships available within Laravel, including:
In fact, the
belongsTo relationship is automatically generated for any column defined with the
id column type.
To define one of the additional relationships, you may add a
relationships section to your model definition. Within this section, you specify the relationship type followed by a comma separated list of model names.
For example, the following definition adds some common relationships to a
models: Post: title: string:400 published_at: timestamp nullable relationships: hasMany: Comment belongsToMany: Media, Site
While you may specify the
relationships anywhere within the model section, Blueprint recommends doing so at the bottom.
For each of these relationships, Blueprint will add the respective Eloquent relationship method within the generated model class. In addition, Blueprint will automatically generate the "pivot table" migration for any