<small id='oi1CJ'></small><noframes id='oi1CJ'>

    1. <i id='oi1CJ'><tr id='oi1CJ'><dt id='oi1CJ'><q id='oi1CJ'><span id='oi1CJ'><b id='oi1CJ'><form id='oi1CJ'><ins id='oi1CJ'></ins><ul id='oi1CJ'></ul><sub id='oi1CJ'></sub></form><legend id='oi1CJ'></legend><bdo id='oi1CJ'><pre id='oi1CJ'><center id='oi1CJ'></center></pre></bdo></b><th id='oi1CJ'></th></span></q></dt></tr></i><div id='oi1CJ'><tfoot id='oi1CJ'></tfoot><dl id='oi1CJ'><fieldset id='oi1CJ'></fieldset></dl></div>
    2. <legend id='oi1CJ'><style id='oi1CJ'><dir id='oi1CJ'><q id='oi1CJ'></q></dir></style></legend>

        <bdo id='oi1CJ'></bdo><ul id='oi1CJ'></ul>
    3. <tfoot id='oi1CJ'></tfoot>
    4. Laravel 仓库

      Laravel Repositories(Laravel 仓库)
    5. <i id='ic2Ac'><tr id='ic2Ac'><dt id='ic2Ac'><q id='ic2Ac'><span id='ic2Ac'><b id='ic2Ac'><form id='ic2Ac'><ins id='ic2Ac'></ins><ul id='ic2Ac'></ul><sub id='ic2Ac'></sub></form><legend id='ic2Ac'></legend><bdo id='ic2Ac'><pre id='ic2Ac'><center id='ic2Ac'></center></pre></bdo></b><th id='ic2Ac'></th></span></q></dt></tr></i><div id='ic2Ac'><tfoot id='ic2Ac'></tfoot><dl id='ic2Ac'><fieldset id='ic2Ac'></fieldset></dl></div>

      • <tfoot id='ic2Ac'></tfoot>
          <bdo id='ic2Ac'></bdo><ul id='ic2Ac'></ul>

            <tbody id='ic2Ac'></tbody>

        • <small id='ic2Ac'></small><noframes id='ic2Ac'>

          1. <legend id='ic2Ac'><style id='ic2Ac'><dir id='ic2Ac'><q id='ic2Ac'></q></dir></style></legend>

              1. 本文介绍了Laravel 仓库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                Laravel 中的存储库有什么优势?它似乎是从应用程序的业务逻辑中抽象出模型层.尽管它实际上似乎只是让整个请求生命周期变得更加复杂,但收效甚微.

                What are the advantages of Repositories in Laravel? It seems to be abstracting the Model layer from the business logic of the application. Although it really just seems to make the whole request life cycle just that much more complicated for little gain.

                有人可以阐明 Laravel 存储库的优势吗?

                Can someone shed light on the advantage of Laravel repositories?

                现在使用存储库一段时间后,我将添加以下内容:

                After now using repositories for some time I would add the following:

                • 存储库执行单一职责
                • 存储库应该只返回一个实体集合
                • 虽然与依赖注入不同,但概念是兄弟
                • 实际存储实现的存储抽象(例如 MySQL)
                • 更轻松的测试

                推荐答案

                存储库,就像在提供的教程中一样,不是 Laravel 概念所必需的.相反,它们是 Laravel 可以实现的一种 IoC 注入形式.任何可能同样被注入的对象并不意味着它是一个存储库.有关 Taylor Otwell 的一个很好的示例,请参阅视频,它恰好也使用了存储库":http://vimeo.com/53029232.

                Repositories, like in the provided tutorial, aren't necessary a Laravel concept. Rather, they're a form of IoC injection that is possible with Laravel. Any object that might similarly be injected doesn't mean it's a repository. See the video for a good example from Taylor Otwell, which happens to use a "repository" as well: http://vimeo.com/53029232.

                在此示例中,存储库抽象出数据的来源,并将其传递给控制器.只要传递的数据实现了指定的接口,控制器就可以愉快地"使用接口定义的方法,而不必担心数据最初来自哪里.这允许在不破坏控制器的情况下切换数据的初始源.您可以从文件、数据库、外部 API、模拟对象或任意数组中提取数据.基本上,控制器不需要收集存储库表示的数据.它可以接收和使用.

                In this example, the repository abstracts where the data came from that is passed to the controller. As long as the data passed implements the specified interface, the controller can "blissfully" make use of the interface's defined methods without worry about where the data initially came from. This allows switching the initial source of the data without breaking your controller. You could pull the data from a file, a database, an outside API, a mock object, or just some arbitrary array. Basically, the controller doesn't need to gather the data represented by the repository. It can just receive and use.

                这篇关于Laravel 仓库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                <legend id='iKF0j'><style id='iKF0j'><dir id='iKF0j'><q id='iKF0j'></q></dir></style></legend>
                    <tbody id='iKF0j'></tbody>

                    <i id='iKF0j'><tr id='iKF0j'><dt id='iKF0j'><q id='iKF0j'><span id='iKF0j'><b id='iKF0j'><form id='iKF0j'><ins id='iKF0j'></ins><ul id='iKF0j'></ul><sub id='iKF0j'></sub></form><legend id='iKF0j'></legend><bdo id='iKF0j'><pre id='iKF0j'><center id='iKF0j'></center></pre></bdo></b><th id='iKF0j'></th></span></q></dt></tr></i><div id='iKF0j'><tfoot id='iKF0j'></tfoot><dl id='iKF0j'><fieldset id='iKF0j'></fieldset></dl></div>
                    1. <tfoot id='iKF0j'></tfoot>
                        <bdo id='iKF0j'></bdo><ul id='iKF0j'></ul>

                        • <small id='iKF0j'></small><noframes id='iKF0j'>