如何在 Laravel 中创建一条包罗万象的路线

编程入门 行业动态 更新时间:2024-10-10 19:22:47
本文介绍了如何在 Laravel 中创建一条包罗万象的路线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要一个 laravel routes.php 条目,该条目将捕获网站特定 domain/premium-section 的所有流量,以便我可以在访问高级内容之前提示人们成为会员.

I need a laravel routes.php entry that will catch all traffic to a specific domain/premium-section of the site so that I can prompt people to become members before accessing the premium content.

推荐答案

  • 在 app/Http/routes.php 中,我创建了一个路由,该路由将捕获 domain/premium-section/anywhere/they/try/to/go 中的所有流量,并尝试在 PremiumSectionController 中查找并执行匹配函数
  • 但是没有任何匹配的方法,只是一个包罗万象的方法.

  • In app/Http/routes.php I create a route that will catch all traffic within domain/premium-section/anywhere/they/try/to/go and attempt to find and execute a matching function within PremiumSectionController
  • But there aren't any matching methods, just a catch-all. Route::group(['as' => 'premium-section::', 'prefix' => 'premium-section', 'middleware' => ['web']], function(){ Route::any('', 'PremiumSectionController@premiumContentIndex'); Route::controller('/', 'PremiumSectionController'); });

  • .

    namespace AppHttpControllers; use ... class PremiumSectionController extends Controller{ public function premiumContentIndex(){ return 'no extra parameters'; } //magically gets called by laravel public function missingMethod($parameters = array()){ return $parameters; } }

    更多推荐

    如何在 Laravel 中创建一条包罗万象的路线

    本文发布于:2023-11-28 08:46:06,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1641721.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:包罗万象   路线   如何在   Laravel

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!