{"id":747,"date":"2025-06-11T22:43:44","date_gmt":"2025-06-11T14:43:44","guid":{"rendered":"https:\/\/www.zhaozhao123.cn\/php\/php-application-manual\/laravel\/747.html"},"modified":"2025-06-11T22:43:44","modified_gmt":"2025-06-11T14:43:44","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8-laravel-%e4%b8%ad%e8%8e%b7%e5%8f%96%e5%bd%93%e5%89%8d%e8%b7%af%e7%94%b1","status":"publish","type":"my1js","link":"https:\/\/www.zhaozhao123.cn\/php\/my1js\/747.html","title":{"rendered":"\u5982\u4f55\u5728 Laravel \u4e2d\u83b7\u53d6\u5f53\u524d\u8def\u7531"},"content":{"rendered":"<div class=\"wp-block-columns p-0 border is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<div class=\"wp-block-columns px-4 py-3 border-bottom has-background is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\" style=\"background:linear-gradient(243deg,rgb(238,238,238) 0%,rgba(58,166,242,0.15) 100%)\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<div class=\"wp-block-group is-nowrap is-layout-flex wp-container-core-group-is-layout-6c531013 wp-block-group-is-layout-flex\">\r\n<figure class=\"wp-block-image size-thumbnail is-resized is-style-rounded is-style-rounded--1\"><img decoding=\"async\" src=\"https:\/\/www.zhaozhao123.cn\/myitems\/images\/sites16\/2025\/06\/dyA-1-400x300.jpg\" alt=\"Bug&#32534;&#35793;&#29422;\" class=\"wp-image-1842\" style=\"object-fit:cover;width:30px;height:30px\"><\/figure>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading my-0\" style=\"font-size:clamp(0.875rem, 0.875rem + ((1vw - 0.2rem) * 0.175), 1rem);\">Bug&#32534;&#35793;&#29422;<\/h2>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n\r\n\r\n\r\n<div class=\"wp-block-columns px-xl-5 px-4 py-xl-4 py-3 is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<p>&#22312; Laravel &#20013;&#65292;&#20320;&#21487;&#20197;&#36890;&#36807;&#22810;&#31181;&#26041;&#24335;&#26469;&#33719;&#21462;&#24403;&#21069;&#30340;&#36335;&#30001;&#20449;&#24687;&#12290;&#20197;&#19979;&#26159;&#20960;&#31181;&#24120;&#35265;&#30340;&#26041;&#27861;&#65306;<\/p>\n<h3>1. &#20351;&#29992; <code>Route::current()<\/code> &#26041;&#27861;<\/h3>\n<p><code>Route::current()<\/code> &#26159; Laravel &#25552;&#20379;&#30340;&#19968;&#20010;&#38745;&#24577;&#26041;&#27861;&#65292;&#29992;&#20110;&#36820;&#22238;&#24403;&#21069;&#35831;&#27714;&#30340;&#36335;&#30001;&#23454;&#20363;&#12290;<\/p>\n<pre><code class=\"language-php\">$currentRoute = Route::current();<\/code><\/pre>\n<h3>2. &#20351;&#29992; <code>request()-&gt;route()<\/code> &#26041;&#27861;<\/h3>\n<p>&#22914;&#26524;&#20320;&#22312;&#19968;&#20010;&#25511;&#21046;&#22120;&#30340;&#26041;&#27861;&#20013;&#65292;&#21487;&#20197;&#30452;&#25509;&#20351;&#29992; <code>request()-&gt;route()<\/code> &#26469;&#33719;&#21462;&#24403;&#21069;&#35831;&#27714;&#30340;&#36335;&#30001;&#23454;&#20363;&#12290;<\/p>\n<pre><code class=\"language-php\">public function someMethod()\n{\n    $currentRoute = request()-&gt;route();\n}<\/code><\/pre>\n<h3>3. &#20351;&#29992; <code>Route::currentRouteName()<\/code> &#26041;&#27861;<\/h3>\n<p><code>Route::currentRouteName()<\/code> &#26041;&#27861;&#29992;&#20110;&#36820;&#22238;&#24403;&#21069;&#35831;&#27714;&#30340;&#36335;&#30001;&#21517;&#31216;&#12290;<\/p>\n<pre><code class=\"language-php\">$currentRouteName = Route::currentRouteName();<\/code><\/pre>\n<h3>&#31034;&#20363;&#20195;&#30721;<\/h3>\n<p>&#20197;&#19979;&#26159;&#19968;&#20010;&#23436;&#25972;&#30340;&#31034;&#20363;&#65292;&#23637;&#31034;&#20102;&#22914;&#20309;&#22312;&#25511;&#21046;&#22120;&#20013;&#33719;&#21462;&#24403;&#21069;&#36335;&#30001;&#30340;&#20449;&#24687;&#65306;<\/p>\n<pre><code class=\"language-php\">namespace AppHttpControllers;\n\nuse IlluminateHttpRequest;\nuse IlluminateSupportFacadesRoute;\n\nclass ExampleController extends Controller\n{\n    public function someMethod()\n    {\n        \/\/ &#33719;&#21462;&#24403;&#21069;&#36335;&#30001;&#23454;&#20363;\n        $currentRoute = Route::current();\n\n        \/\/ &#33719;&#21462;&#24403;&#21069;&#36335;&#30001;&#21517;&#31216;\n        $currentRouteName = Route::currentRouteName();\n\n        \/\/ &#36755;&#20986;&#24403;&#21069;&#36335;&#30001;&#21644;&#36335;&#30001;&#21517;&#31216;\n        echo \"Current Route: \" . $currentRoute-&gt;uri() . \"n\";\n        echo \"Current Route Name: \" . $currentRouteName . \"n\";\n\n        \/\/ &#22914;&#26524;&#38656;&#35201;&#35775;&#38382;&#21442;&#25968;&#65292;&#21487;&#20197;&#20351;&#29992; $request-&gt;route('param_name')\n        $parameter = request()-&gt;route('param_name');\n        echo \"Parameter: \" . $parameter . \"n\";\n    }\n}<\/code><\/pre>\n<p>&#22312;&#36825;&#20010;&#31034;&#20363;&#20013;&#65292;&#25105;&#20204;&#39318;&#20808;&#33719;&#21462;&#20102;&#24403;&#21069;&#35831;&#27714;&#30340;&#36335;&#30001;&#23454;&#20363;&#65292;&#24182;&#36755;&#20986;&#20102;&#20854; URI &#21644;&#21517;&#31216;&#12290;&#28982;&#21518;&#65292;&#25105;&#20204;&#36824;&#23637;&#31034;&#20102;&#22914;&#20309;&#20174;&#24403;&#21069;&#36335;&#30001;&#20013;&#25552;&#21462;&#21442;&#25968;&#12290;<\/p>\n<p>&#24076;&#26395;&#36825;&#20123;&#20449;&#24687;&#23545;&#20320;&#26377;&#24110;&#21161;&#65281;<\/p>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<\/div><div class=\"wp-block-columns p-0 border is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<div class=\"wp-block-columns px-4 py-3 border-bottom has-background is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\" style=\"background:linear-gradient(243deg,rgb(238,238,238) 0%,rgba(58,166,242,0.15) 100%)\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<div class=\"wp-block-group is-nowrap is-layout-flex wp-container-core-group-is-layout-6c531013 wp-block-group-is-layout-flex\">\r\n<figure class=\"wp-block-image size-thumbnail is-resized is-style-rounded is-style-rounded--2\"><img decoding=\"async\" src=\"https:\/\/www.zhaozhao123.cn\/myitems\/images\/sites16\/2025\/06\/zp-400x300.jpg\" alt=\"&#40657;&#26495;Bug&#35762;&#24072;\" class=\"wp-image-1849\" style=\"object-fit:cover;width:30px;height:30px\"><\/figure>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading my-0\" style=\"font-size:clamp(0.875rem, 0.875rem + ((1vw - 0.2rem) * 0.175), 1rem);\">&#40657;&#26495;Bug&#35762;&#24072;<\/h2>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n\r\n\r\n\r\n<div class=\"wp-block-columns px-xl-5 px-4 py-xl-4 py-3 is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<body><h2>&#20171;&#32461;<\/h2><p>&#22312;&#20351;&#29992;Laravel&#26694;&#26550;&#26500;&#24314;&#24212;&#29992;&#26102;&#65292;&#30830;&#23450;&#24403;&#21069;&#36335;&#30001;&#38750;&#24120;&#37325;&#35201;&#65292;&#23588;&#20854;&#26159;&#22312;&#20381;&#36182;&#20110;&#36335;&#30001;&#23646;&#24615;&#30340;&#21151;&#33021;&#19978;&#65292;&#20363;&#22914;&#20013;&#38388;&#20214;&#12289;&#35775;&#38382;&#25511;&#21046;&#25110;&#21160;&#24577;&#35774;&#32622;&#23548;&#33322;&#26639;&#20013;&#30340;&#27963;&#36291;&#29366;&#24577;&#31561;&#12290;&#20102;&#35299;&#22914;&#20309;&#33719;&#21462;&#24403;&#21069;&#36335;&#30001;&#20449;&#24687;&#23545;&#20110;&#26377;&#25928;&#21644;&#21160;&#24577;&#30340;Laravel&#24212;&#29992;&#31243;&#24207;&#24320;&#21457;&#33267;&#20851;&#37325;&#35201;&#12290;<\/p><p>&#22312;Laravel&#20013;&#65292;&#36335;&#30001;&#20449;&#24687;&#30001;&#36335;&#30001;&#25511;&#21046;&#22120;&#22788;&#29702;&#12290;<code>Route<\/code>&#35013;&#39280;&#22120;&#65288;facade&#65289;&#25552;&#20379;&#20102;&#19982;&#24212;&#29992;&#36335;&#30001;&#20132;&#20114;&#30340;&#22810;&#31181;&#26041;&#27861;&#12290;&#22312;&#26412;&#25945;&#31243;&#20013;&#65292;&#25105;&#20204;&#23558;&#25506;&#32034;&#21508;&#31181;&#33719;&#21462;&#24403;&#21069;&#36335;&#30001;&#30340;&#26041;&#27861;&#24182;&#22312;&#24744;&#30340;&#24212;&#29992;&#31243;&#24207;&#20013;&#21033;&#29992;&#36825;&#20123;&#36335;&#30001;&#12290;<\/p><h2>&#27491;&#22312;&#35775;&#38382;&#24403;&#21069;&#36335;&#30001;&#12290;<\/h2><p>&#39318;&#20808;&#65292;&#20320;&#21487;&#20197;&#36890;&#36807;&#20351;&#29992;&#24403;&#21069;&#36335;&#32447;&#26469;&#35775;&#38382;&#23427;&#12290;<code>current<\/code>&#25552;&#20379;&#30340;&#26041;&#27861;&#30001;&#24744;&#25552;&#20379;&#12290;<code>Route<\/code>&#35013;&#39280;&#22120;&#12290;&#36825;&#26159;&#23427;&#30340;&#29992;&#27861;&#65306;<\/p><pre><code>use IlluminateSupportFacadesRoute;\n\n\/\/ Get the current route\n$route = Route::current();\n<\/code><\/pre><p>&#36825;&#23558;&#36820;&#22238;&#24403;&#21069;&#36335;&#30001;&#30340;&#23454;&#20363;&#65292;&#20320;&#21487;&#20197;&#20351;&#29992;&#23427;&#26469;&#25552;&#21462;&#36827;&#19968;&#27493;&#30340;&#20449;&#24687;&#12290;<\/p><h2>&#33719;&#21462;&#36335;&#32447;&#21517;&#31216;<\/h2><p>Laravel &#20801;&#35768;&#36335;&#30001;&#21629;&#21517;&#65292;&#20197;&#20415;&#20110;&#26041;&#20415;&#30340;&#24341;&#29992;&#12290;&#35201;&#33719;&#21462;&#24403;&#21069;&#36335;&#30001;&#30340;&#21517;&#23383;&#65292;&#20320;&#21487;&#20197;&#20351;&#29992;&#20197;&#19979;&#20195;&#30721;&#65306;<code>currentRouteName<\/code>&#26041;&#27861;&#65306;<\/p><pre><code>\/\/ Get the name of the current route\n$routeName = Route::currentRouteName();\n<\/code><\/pre><p>&#22914;&#26524;&#38656;&#35201;&#22312;&#35270;&#22270;&#25110;&#20013;&#38388;&#20214;&#20013;&#23545;&#24403;&#21069;&#36335;&#32447;&#30340;&#21517;&#31216;&#36827;&#34892;&#26816;&#26597;&#65292;&#20320;&#21487;&#20197;&#36825;&#26679;&#20570;&#65306;<\/p><pre><code>if (Route::currentRouteName() === 'home') {\n    \/\/ Do something specific for the home route\n}\n<\/code><\/pre><h2>&#33719;&#21462;URL&#21644;&#36335;&#30001;&#21442;&#25968;<\/h2><p>&#38500;&#20102;&#21517;&#31216;&#65292;&#24744;&#36824;&#21487;&#20197;&#26816;&#32034;&#36335;&#32447;&#30340;URL&#25110;&#20219;&#20309;&#36890;&#36807;URL&#20256;&#36882;&#30340;&#21442;&#25968;&#12290;&#24744;&#21487;&#20197;&#20351;&#29992;&#20197;&#19979;&#26041;&#27861;&#26469;&#23436;&#25104;&#27492;&#25805;&#20316;&#65306;<code>currentRouteAction<\/code>and &#26159;&ldquo;&#24182;&#19988;&rdquo;&#30340;&#24847;&#24605;&#12290;<code>current<\/code>&#36825;&#20123;&#26041;&#27861;&#30340;&#21442;&#25968;&#20998;&#21035;&#20026;&#65306;<\/p><pre><code>\/\/ Get the full URL to the current route\n$currentUrl = url(Route::current()-&gt;uri());\n\n\/\/ Get the current route parameters\n$routeParameters = Route::current()-&gt;parameters();\n<\/code><\/pre><p>&#36825;&#20123;&#21442;&#25968;&#36890;&#24120;&#26159;&#22312;&#36335;&#30001;&#30340;URL&#20013;&#23450;&#20041;&#30340;&#65292;&#20363;&#22914;&#65306;<\/p><pre><code>Route::get('\/user\/{id}', function ($id) {\n    \/\/ Your logic here\n})-&gt;name('user.show');\n<\/code><\/pre><p>&#22312;&#19978;&#36848;&#36335;&#32447;&#20013;&#65292;&#26377;&#19968;&#20010;&#21442;&#25968;&#12290;<code>{id}<\/code>&#37027;&#20320;&#21487;&#20197;&#36890;&#36807;&#26576;&#31181;&#26041;&#24335;&#33719;&#21462;&#30340;&#12290;<code>parameters<\/code>&#26041;&#27861;&#12290;<\/p><h2>&#20351;&#29992;Route Facade&#30340;&#36741;&#21161;&#20989;&#25968;&#12290;<\/h2><p>Laravel &#25552;&#20379;&#20102;&#22810;&#20010;&#21487;&#20197;&#30452;&#25509;&#20351;&#29992;&#30340;&#21161;&#25163;&#20989;&#25968;&#65292;&#32780;&#19981;&#26159;&#35843;&#29992;&#26041;&#27861;&#12290;<code>Route<\/code>Facade. &#20197;&#19979;&#26159;&#19968;&#20123;&#20363;&#23376;&#65306;<\/p><pre><code>\/\/ Using the helper function to get the current route\n$route = request()-&gt;route();\n\n\/\/ Getting the current route name\n$routeName = request()-&gt;route()-&gt;getName();\n\n\/\/ Getting current route action\n$routeAction = request()-&gt;route()-&gt;getActionName();\n\n\/\/ Getting route parameters values\n$userId = request()-&gt;route('id');\n<\/code><\/pre><p>&#23545;&#19981;&#36215;&#65292;&#24744;&#30340;&#38382;&#39064;&#19981;&#26126;&#30830;&#65292;&#35831;&#24744;&#37325;&#26032;&#25551;&#36848;&#19968;&#19979;&#12290;<code>request()<\/code>&#35813;&#21151;&#33021;&#25552;&#20379;&#20102;&#19968;&#31181;&#26041;&#20415;&#30340;&#26041;&#24335;&#26469;&#35775;&#38382;&#24403;&#21069;&#35831;&#27714;&#20449;&#24687;&#65292;&#21253;&#25324;&#36335;&#30001;&#12290;<\/p><h2>&#22522;&#20110;&#36335;&#30001;&#27169;&#24335;&#30340;&#26465;&#20214;&#26816;&#26597;<\/h2><p>&#26377;&#26102;&#65292;&#24744;&#21487;&#33021;&#24076;&#26395;&#26681;&#25454;&#36335;&#30001;&#21517;&#31216;&#36981;&#24490;&#30340;&#27169;&#24335;&#25191;&#34892;&#25805;&#20316;&#12290;&#24744;&#21487;&#20197;&#20351;&#29992;&#20197;&#19979;&#20195;&#30721;&#26469;&#23454;&#29616;&#36825;&#19968;&#28857;&#65306;<code>is<\/code>&#26041;&#27861;&#22914;&#19979;&#65306;<\/p><pre><code>\/\/ Check if the route name matches a pattern\nif (Route::is('admin.*')) {\n    \/\/ The route name starts with 'admin.'\n}\n<\/code><\/pre><p>&#36825;&#22312;&#26681;&#25454;&#32593;&#31449;&#30340;&#26576;&#19968;&#37096;&#20998;&#35774;&#32622;&#27963;&#21160;&#29366;&#24577;&#26041;&#38754;&#23588;&#20854;&#26377;&#29992;&#12290;<\/p><h2>&#20013;&#38388;&#20214;&#21644;&#36335;&#30001;&#20449;&#24687;<\/h2><p>&#22312;&#20013;&#38388;&#20214;&#20013;&#65292;&#35775;&#38382;&#24403;&#21069;&#36335;&#30001;&#26159;&#19968;&#39033;&#24120;&#35265;&#30340;&#20219;&#21153;&#12290;&#20013;&#38388;&#20214;&#26041;&#27861;&#21487;&#20197;&#35775;&#38382;&#21040;<code>$request<\/code>&#23545;&#35937;&#65292;&#20174;&#32780;&#21487;&#20197;&#32473;&#20320;&#36335;&#32447;&#65306;<\/p><pre><code>public function handle($request, Closure $next)\n{\n    $currentRoute = $request-&gt;route();\n    \/\/ Your logic here\n\n    return $next($request);\n}\n<\/code><\/pre><p>&#36825;&#20801;&#35768;&#20320;&#22312;&#20013;&#38388;&#20214;&#20869;&#22522;&#20110;&#36335;&#32447;&#25191;&#34892;&#39564;&#35777;&#25110;&#20462;&#25913;&#25805;&#20316;&#12290;<\/p><h2>&#22312;&#35270;&#22270;&#20013;&#26174;&#31034;&#36335;&#30001;&#20449;&#24687;<\/h2><p>&#20026;&#20102;&#22312;&#23548;&#33322;&#20803;&#32032;&#25110;&#38754;&#21253;&#23633;&#26465;&#30340;&#35270;&#22270;&#20013;&#26174;&#31034;&#24403;&#21069;&#36335;&#32447;&#20449;&#24687;&#65292;&#21487;&#20197;&#30452;&#25509;&#20351;&#29992;&#12290;<code>Route<\/code>&#35831;&#25552;&#20379;&#38656;&#35201;&#32763;&#35793;&#30340;&#20869;&#23481;&#12290;<\/p><pre><code>&lt;ul&gt;\n    &lt;li class=\"{{ Route::is('home') ? 'active' : '' }}\"&gt;Home&lt;\/li&gt;\n    &lt;li class=\"{{ Route::is('about') ? 'active' : '' }}\"&gt;About&lt;\/li&gt;\n    &lt;li class=\"{{ Route::is('contact') ? 'active' : '' }}\"&gt;Contact&lt;\/li&gt;\n&lt;\/ul&gt;\n<\/code><\/pre><p>&#26816;&#26597;&#27963;&#36291;&#30340;&#36335;&#30001;&#21487;&#20197;&#29992;&#26469;&#22312;&#24212;&#29992;&#31243;&#24207;&#30340;UI&#20869;&#21019;&#24314;&#21160;&#24577;&#29992;&#25143;&#20307;&#39564;&#12290;<\/p><h2>&#32467;&#35770;<\/h2><p>&#29702;&#35299;&#22914;&#20309;&#22312;Laravel&#20013;&#33719;&#21462;&#24403;&#21069;&#36335;&#30001;&#21450;&#20854;&#23646;&#24615;&#23545;&#20110;&#26500;&#24314;&#21160;&#24577;&#21644;&#21709;&#24212;&#24335;&#24212;&#29992;&#31243;&#24207;&#33267;&#20851;&#37325;&#35201;&#12290;&#26412;&#25945;&#31243;&#20171;&#32461;&#20102;Laravel&#26694;&#26550;&#25552;&#20379;&#30340;&#21508;&#31181;&#26041;&#27861;&#65292;&#20197;&#35775;&#38382;&#21644;&#25805;&#20316;&#36335;&#30001;&#20449;&#24687;&#65292;&#20197;&#28385;&#36275;&#24744;&#30340;&#24212;&#29992;&#38656;&#27714;&#12290;&#36890;&#36807;&#21033;&#29992;Laravel&#30340;&#24378;&#22823;&#36335;&#30001;&#21151;&#33021;&#65292;&#21253;&#25324;&#21629;&#21517;&#36335;&#30001;&#21644;&#20013;&#38388;&#20214;&#65292;&#24320;&#21457;&#20154;&#21592;&#21487;&#20197;&#26356;&#39640;&#25928;&#22320;&#25511;&#21046;&#24212;&#29992;&#31243;&#24207;&#30340;&#27969;&#31243;&#21644;&#36923;&#36753;&#12290;<\/p><p>&#29616;&#22312;&#24744;&#24050;&#32463;&#23398;&#20250;&#20102;&#22914;&#20309;&#33719;&#21462;&#24403;&#21069;&#30340;&#36335;&#30001;&#20449;&#24687;&#65292;&#21487;&#20197;&#22312;&#24744;&#30340;Laravel&#24212;&#29992;&#20013;&#23454;&#39564;&#20351;&#29992;&#36825;&#20123;&#26041;&#27861;&#26469;&#20248;&#21270;&#25511;&#21046;&#22120;&#12289;&#35270;&#22270;&#21644;&#20013;&#38388;&#20214;&#12290;&#36825;&#23558;&#24110;&#21161;&#24744;&#30340;&#24212;&#29992;&#31243;&#24207;&#21464;&#24471;&#26356;&#21152;&#20102;&#35299;&#24182;&#21709;&#24212;&#29992;&#25143;&#25191;&#34892;&#30340;&#21160;&#20316;&#12290;<\/p><\/body>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<\/div><div class=\"wp-block-columns p-0 border is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<div class=\"wp-block-columns px-4 py-3 border-bottom has-background is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\" style=\"background:linear-gradient(243deg,rgb(238,238,238) 0%,rgba(58,166,242,0.15) 100%)\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<div class=\"wp-block-group is-nowrap is-layout-flex wp-container-core-group-is-layout-6c531013 wp-block-group-is-layout-flex\">\r\n<figure class=\"wp-block-image size-thumbnail is-resized is-style-rounded is-style-rounded--3\"><img decoding=\"async\" src=\"https:\/\/www.zhaozhao123.cn\/myitems\/images\/sites16\/2025\/06\/xygcfznnzczhsdmwydzhsmzzzmddnq-400x300.jpg\" alt=\"&#38271;&#24037;&#30721;&#22900;1523\" class=\"wp-image-2906\" style=\"object-fit:cover;width:30px;height:30px\"><\/figure>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading my-0\" style=\"font-size:clamp(0.875rem, 0.875rem + ((1vw - 0.2rem) * 0.175), 1rem);\">&#38271;&#24037;&#30721;&#22900;1523<\/h2>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n\r\n\r\n\r\n<div class=\"wp-block-columns px-xl-5 px-4 py-xl-4 py-3 is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<p>&#35201;&#22312; Laravel &#20013;&#33719;&#21462;&#24403;&#21069;&#36335;&#30001;&#65292;&#20320;&#21487;&#20197;&#20351;&#29992;&#20197;&#19979;&#26041;&#27861;&#65306;<\/p>\n<p>&#39318;&#20808;&#65292;&#30830;&#20445;&#20320;&#22312;&#39033;&#30446;&#20013;&#23433;&#35013;&#20102; Laravel&#12290;&#28982;&#21518;&#65292;&#25171;&#24320; <code>app\/Http\/Middleware\/VerifyCsrfToken.php<\/code> &#25991;&#20214;&#12290;<\/p>\n<p>&#22312;&#36825;&#20010;&#25991;&#20214;&#20013;&#65292;&#25214;&#21040;&#24182;&#20462;&#25913; <code>$this-&gt;routeMiddleware<\/code> &#25968;&#32452;&#20013;&#30340;&#31532;&#19968;&#20010;&#20803;&#32032;&#65288;&#21363;&#40664;&#35748;&#30340;&#39564;&#35777; CSRF &#30340;&#20013;&#38388;&#20214;&#65289;&#12290;&#23558;&#35813;&#20013;&#38388;&#20214;&#26367;&#25442;&#20026;&#19968;&#20010;&#33258;&#23450;&#20041;&#30340;&#20013;&#38388;&#20214;&#65292;&#29992;&#20110;&#33719;&#21462;&#24403;&#21069;&#36335;&#30001;&#20449;&#24687;&#12290;<\/p>\n<pre><code class=\"language-php\">$this-&gt;routeMiddleware([\n    \/\/ ...&#20854;&#20182;&#20013;&#38388;&#20214;...\n    'verify-current-route' =&gt; AppHttpMiddlewareVerifyCurrentRoute::class,\n]);<\/code><\/pre>\n<p>&#25509;&#19979;&#26469;&#65292;&#21019;&#24314;&#19968;&#20010;&#26032;&#30340;&#20013;&#38388;&#20214;&#31867;&#65292;&#20363;&#22914; <code>GetCurrentRouteMiddleware.php<\/code>&#65306;<\/p>\n<pre><code class=\"language-php\">&lt;?php\n\nnamespace AppHttpMiddleware;\n\nuse Closure;\nuse IlluminateSupportFacadesRoute;\n\nclass GetCurrentRouteMiddleware\n{\n    \/**\n     * Handle an incoming request.\n     *\n     * @param  IlluminateHttpRequest  $request\n     * @param  Closure  $next\n     * @return mixed\n     *\/\n    public function handle($request, Closure $next)\n    {\n        \/\/ &#33719;&#21462;&#24403;&#21069;&#36335;&#30001;\n        $currentRoute = Route::getCurrentRoute();\n\n        return $next($request);\n    }\n}<\/code><\/pre>\n<p>&#29616;&#22312;&#65292;&#20320;&#38656;&#35201;&#22312;&#25511;&#21046;&#22120;&#25110;&#20854;&#20182;&#38656;&#35201;&#22788;&#29702;&#35831;&#27714;&#30340;&#22320;&#26041;&#28155;&#21152;&#36825;&#20010;&#26032;&#30340;&#20013;&#38388;&#20214;&#12290;&#20363;&#22914;&#65292;&#22312; <code>AppHttpControllersController.php<\/code> &#20013;&#28155;&#21152;&#22914;&#19979;&#20195;&#30721;&#65306;<\/p>\n<pre><code class=\"language-php\">protected function dispatch(Request $request)\n{\n    \/\/ &#22312;&#36825;&#37324;&#35843;&#29992;&#24744;&#30340;&#36923;&#36753;\n    \/\/ ...\n\n    \/\/ &#28155;&#21152;&#24403;&#21069;&#36335;&#30001;&#21040;&#21709;&#24212;\n    $response = $this-&gt;handleResponse(...);\n\n    \/\/ &#36820;&#22238;&#21709;&#24212;\n    return response()-&gt;json($response, 200);\n}\n\nprotected function handleResponse(array $response)\n{\n    \/\/ &#22312;&#36825;&#37324;&#22788;&#29702;&#21709;&#24212;&#25968;&#25454;\n    \/\/ ...\n\n    \/\/ &#33719;&#21462;&#24403;&#21069;&#36335;&#30001;\n    $currentRoute = Route::getCurrentRoute();\n    if ($currentRoute) {\n        \/\/ &#22914;&#26524;&#26377;&#24403;&#21069;&#36335;&#30001;&#65292;&#21017;&#28155;&#21152;&#21040;&#21709;&#24212;\n        $response['current_route'] = $currentRoute-&gt;uri();\n    }\n\n    return $response;\n}<\/code><\/pre>\n<p>&#26368;&#21518;&#65292;&#35201;&#21551;&#29992;&#36825;&#20010;&#20013;&#38388;&#20214;&#65292;&#35831;&#22312; <code>config\/app.php<\/code> &#25991;&#20214;&#20013;&#28155;&#21152;&#20197;&#19979;&#37197;&#32622;&#65306;<\/p>\n<pre><code class=\"language-php\">'middlewares' =&gt; [\n    \/\/ ...\n    'verify-current-route' =&gt; true,\n],<\/code><\/pre>\n<p>&#36825;&#26679;&#65292;&#24403;&#29992;&#25143;&#35775;&#38382;&#20219;&#20309;&#39029;&#38754;&#26102;&#65292;Laravel &#23558;&#20250;&#33258;&#21160;&#26816;&#26597;&#24403;&#21069;&#36335;&#30001;&#65292;&#24182;&#23558;&#20854;&#28155;&#21152;&#21040;&#21709;&#24212;&#20013;&#12290;<\/p>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Bug&#32534;&#35793;&#29422; &#22312; Laravel &#20013;&#65292;&#20320;&#21487;&#20197;&#36890;&#36807;&#22810;&#31181;&#26041;&#24335;&#26469;&#33719;&#21462;&#038;#2..<\/p>\n","protected":false},"author":1,"featured_media":0,"menu_order":0,"template":"","meta":{"_acf_changed":false},"tags":[],"my1js2nav":[44],"tuisongtax":[],"class_list":["post-747","my1js","type-my1js","status-publish","hentry","my1js2nav-laravel"],"acf":{"qian_art_seotitle":"","qian_art_seotitle_source":{"label":"SEO\u6807\u9898","type":"text","formatted_value":""},"qian_art_seokws":"","qian_art_seokws_source":{"label":"SEO\u5173\u952e\u8bcd","type":"text","formatted_value":""},"qian_art_stzhong":"","qian_art_stzhong_source":{"label":"\u4e2d | \u77ed\u6807\u9898","type":"text","formatted_value":""}},"_links":{"self":[{"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/my1js\/747","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/my1js"}],"about":[{"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/types\/my1js"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/users\/1"}],"wp:attachment":[{"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/media?parent=747"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/tags?post=747"},{"taxonomy":"my1js2nav","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/my1js2nav?post=747"},{"taxonomy":"tuisongtax","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/tuisongtax?post=747"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}