jarrodtomholt/belongs-to-macro
最新稳定版本:1.0.0
Composer 安装命令:
composer require jarrodtomholt/belongs-to-macro
包简介
Automatically add index and constraints to your migration foreignIdFor entities with a simple macro
README 文档
README
Automatically add index and foreign key constraints to your migrations enforcing data integrity, preserving the referential association and improving query performance.
Installation
You can install the package via composer:
composer require jarrodtomholt/belongs-to-macro
Usage
In a migrations up() method, use the following in place of foreignIdFor to add
indexes and foreign key constraints.
Schema::create('posts', function (Blueprint $table) { $table->belongsTo(User::class); }); // will expand to $table->foreignIdFor(User::class)->index()->constrained();
Need a nullable field? use belongsToOrNull
Schema::create('posts', function (Blueprint $table) { $table->belongsToOrNull(User::class); }); // will expand to $table->foreignIdFor(User::class)->nullable()->index()->constrained();
Testing
composer test
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please raise an issue using the issue tracker.
License
The MIT License (MIT). Please see License File for more information.
Laravel Package Boilerplate
This package was generated using the Laravel Package Boilerplate.
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-01-24