• <legend id='bGztS'><style id='bGztS'><dir id='bGztS'><q id='bGztS'></q></dir></style></legend>

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

    1. <tfoot id='bGztS'></tfoot>

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

        资源控制器的 Laravel 命名路由

        Laravel named route for resource controller(资源控制器的 Laravel 命名路由)

            <tbody id='5I5Xs'></tbody>

              • <bdo id='5I5Xs'></bdo><ul id='5I5Xs'></ul>
                <legend id='5I5Xs'><style id='5I5Xs'><dir id='5I5Xs'><q id='5I5Xs'></q></dir></style></legend>
                <tfoot id='5I5Xs'></tfoot>

                  <small id='5I5Xs'></small><noframes id='5I5Xs'>

                  <i id='5I5Xs'><tr id='5I5Xs'><dt id='5I5Xs'><q id='5I5Xs'><span id='5I5Xs'><b id='5I5Xs'><form id='5I5Xs'><ins id='5I5Xs'></ins><ul id='5I5Xs'></ul><sub id='5I5Xs'></sub></form><legend id='5I5Xs'></legend><bdo id='5I5Xs'><pre id='5I5Xs'><center id='5I5Xs'></center></pre></bdo></b><th id='5I5Xs'></th></span></q></dt></tr></i><div id='5I5Xs'><tfoot id='5I5Xs'></tfoot><dl id='5I5Xs'><fieldset id='5I5Xs'></fieldset></dl></div>
                • 本文介绍了资源控制器的 Laravel 命名路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  使用 Laravel 4.2,是否可以为资源控制器路由分配名称?我的路线定义如下:

                  Using Laravel 4.2, is it possible to assign a name to a resource controller route? My route is defined as follows:

                  Route::resource('faq', 'ProductFaqController');
                  

                  我尝试像这样向路线添加名称选项:

                  I tried adding a name option to the route like this:

                  Route::resource('faq', 'ProductFaqController', array("as"=>"faq"));
                  

                  但是,当我点击/faq 路线并将 {{ Route::currentRouteName() }} 放在我的视图中时,它会产生 faq.faq.index只是faq.

                  However, when I hit the /faq route and place {{ Route::currentRouteName() }} in my view, it yields faq.faq.index instead of just faq.

                  推荐答案

                  当您使用资源控制器路由时,它会自动为其创建的每个单独的路由生成名称.Route::resource() 基本上是一个帮助方法,然后为您生成单独的路由,而不是您需要手动定义每个路由.

                  When you use a resource controller route, it automatically generates names for each individual route that it creates. Route::resource() is basically a helper method that then generates individual routes for you, rather than you needing to define each route manually.

                  您可以在终端/控制台中查看通过在 Laravel 4 中输入 php artisan routes 或在 Laravel 5 中输入 php artisan route:list 生成的路由名称.您还可以在资源控制器文档页面 (Laravel 4.x | Laravel 5.x).

                  You can view the route names generated by typing php artisan routes in Laravel 4 or php artisan route:list in Laravel 5 into your terminal/console. You can also see the types of route names generated on the resource controller docs page (Laravel 4.x | Laravel 5.x).

                  有两种方法可以修改资源控制器生成的路由名称:

                  There are two ways you can modify the route names generated by a resource controller:

                  1. 提供一个 names 数组作为第三个参数 $options 数组的一部分,每个键都是资源控制器方法(索引、存储、编辑等).),并且值是您要为路线提供的名称.

                  1. Supply a names array as part of the third parameter $options array, with each key being the resource controller method (index, store, edit, etc.), and the value being the name you want to give the route.

                  Route::resource('faq', 'ProductFaqController', [
                      'names' => [
                          'index' => 'faq',
                          'store' => 'faq.new',
                          // etc...
                      ]
                  ]);
                  

                • 指定 as 选项以定义每个路由名称的前缀.

                • Specify the as option to define a prefix for every route name.

                  Route::resource('faq', 'ProductFaqController', [
                      'as' => 'prefix'
                  ]);
                  

                  这将为您提供诸如 prefix.faq.indexprefix.faq.store 等路由.

                  This will give you routes such as prefix.faq.index, prefix.faq.store, etc.

                  这篇关于资源控制器的 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='OujeZ'><style id='OujeZ'><dir id='OujeZ'><q id='OujeZ'></q></dir></style></legend>
                        • <bdo id='OujeZ'></bdo><ul id='OujeZ'></ul>

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

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