介绍 IOC 控制反转 Inversion of Control 依赖关系的转移 依赖抽象而非实践 DI 依赖注入 Dependency Injection 不必自己在代码中维护对象的依赖 容器自己主动依据配置.将依赖注入指定对象 IOC.DI对于Laravel的意义 Laravel框架的基础是一个功能强大的控制反转容器(IoC container). 为了真正理解该框架.须要好好掌握该容器.然而我们须要了解.控制反转容器仅仅是一种用于方便实现"依赖注入"的工具. 但要实现依赖注入并不…
简介 编写数据填充类 使用模型工厂类 调用额外填充类 执行填充 #简介 Laravel includes a simple method of seeding your database with test data using seed classes. All seed classes are stored in database/seeds. Seed classes may have any name you wish, but probably should follow some s…
契约接口:app\Contracts\LanguageContract.php <?php namespace App\Contracts; interface LanguageContract { public function speaking(); } 服务类:app\Services\ChineseService.php <?php namespace App\Services; use App\Contracts\LanguageContract; class ChineseServ…
Eloquent: Serialization Introduction Basic Usage Hiding Attributes From JSON Appending Values To JSON Introduction When building JSON APIs, you will often need to convert your models and relationships to arrays or JSON. Eloquent includes convenient m…
Eloquent: Mutators Introduction Accessors & Mutators Date Mutators Attribute Casting Introduction Accessors and mutators allow you to format Eloquent attributes when retrieving them from a model or setting their value. For example, you may want to us…
Eloquent: Collections Introduction Available Methods Custom Collections Introduction All multi-result sets returned by Eloquent are an instance of theIlluminate\Database\Eloquent\Collection object, including results retrieved via the get method or ac…
Eloquent: Relationships Introduction Defining Relationships One To One One To Many Many To Many Has Many Through Polymorphic Relations Many To Many Polymorphic Relations Querying Relations Eager Loading Constraining Eager Loads Lazy Eager Loading Ins…
介绍 建立迁移文件 迁移文件结构 执行迁移 回滚迁移 填写迁移文件 创建表 重命名/ 删除表 创建字段 修改字段 删除字段 建立索引 删除索引 外键约束 #介绍 Migrations are like version control for your database, allowing a team to easily modify and share the application's database schema. Migrations are typically paired wit…