构建Laravel 5项目:掌握Eloquent ORM

5星 · 超过95%的资源 需积分: 10 48 下载量 128 浏览量 更新于2024-07-21 3 收藏 1.75MB PDF 举报
《学习 Laravel 的 Eloquent(Laravel 5 版)》是一本专为开发人员打造的深入指南,旨在帮助读者掌握 Laravel 框架中的 Eloquent ORM(对象关系映射)。作者 Francesco Malatesta 引领读者从创建首个 Laravel 项目开始,一步步构建高效的数据驱动应用。 章节一,读者将学习如何设置项目的环境,包括理解并利用 Laravel 的 Migrations 系统和 Schema Builder 类来设计和管理数据库结构,确保数据模型的精确性和一致性。这一步是理解 Eloquent ORM 基础的关键,因为它为后续操作提供了坚实的基础。 章节的核心内容围绕 Eloquent 模型展开,它被视为独立且可操作的数据实体。读者会学习如何定义模型的属性、验证规则以及与数据库表进行交互。重点在于通过一对多(OneToMany)、一对一(OneToOne)、多对多(ManyToMany)等关系模型来建立数据之间的联系,这在处理复杂数据结构时尤为重要。 接着,章节转向数据的组织、过滤和排序,介绍如何使用 Laravel 的 Collection 类,对查询结果进行灵活的操作,提升应用的性能和用户体验。此外,还会探讨如何利用事件(Event-Driven Architecture)和观察者模式(Observers)扩展功能,增强应用程序的响应性和可维护性。 接近尾声,书中会指导读者在不依赖 Laravel 的情况下安装、配置和使用 Eloquent ORM,这有助于理解和迁移 Eloquent 技术到其他 PHP 应用场景。最后,作者将讨论如何解决复杂的业务问题,以及如何利用 Eloquent 构建高度灵活和适应性强的系统架构。 本书不仅提供技术实践,还强调版权保护,所有内容均受版权法保护,未经许可不得复制或传播。尽管作者和 Packt Publishing 已尽力确保信息的准确性,但读者需自行承担可能存在的错误或误导带来的责任。书中商标信息的准确性由出版社负责,但无法保证所有提及的品牌和产品信息都是最新和准确的。
2016-04-11 上传
What this book covers Chapter 1, Setting Up Our First Project, will discuss how to deal with Composer and Homestead. We will also cover the installation process of our very first Laravel project. Chapter 2, Building the Database with the Schema Builder Class, will discuss the Schema Builder Class. We will analyze everything you can do with the class, look at different types of indexing, and learn about the methods that the Schema class provides. [ v ]Preface Chapter 3, The Most Important Element – the Model!, will help us implement some "create," "read," "update," and "delete" logic for our items. We will also explore some useful methods and features of the model class. Chapter 4, Exploring the World of Relationships, will help us discover how to work with different types of relationships and how to query and use them in a comfortable and clean way. Also, we will learn how to insert and delete related models in our database, or update existing ones. Chapter 5, Using Collections to Enhance Results, will talk about collections. We will work with some results transformation methods and with the elements that make up a collection. Chapter 6, Everything under Control with Events and Observers, will allow us to learn everything about the events in the context of Eloquent models. Right after, we will cover model events and model observers. Chapter 7, Eloquent... without Laravel!, will explore the structure of the database package and see what is inside it. After that, we will learn how to install the "illuminate/database" package separately for your project and how to configure it for its first use. Yes, exactly: Eloquent without Laravel! Chapter 8, It's Not Enough! Extending Eloquent, Advanced Concepts, will explore two different ways to extend Eloquent, and move on to learn about the Repository pattern.