久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Laravel 請求 input() 或 get()

Laravel Request input() or get()(Laravel 請求 input() 或 get())
本文介紹了Laravel 請求 input() 或 get()的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

在 Laravel 5 中,請求對象的方法注入似乎比使用請求門面更受歡迎.

With Laravel 5 it seems like method injection for the Request object is preferred over using the Request facade.

<?php namespace AppHttpControllers;

use IlluminateHttpRequest;

class HomeController extends Controller
{
    public function index(Request $request)
    {
        $email = $request->input('email');

        // OR

        $email = $request->get('email');
    }
}

我有幾個問題:

使用 IlluminateHttpRequest 比使用 IlluminateSupportFacadesRequest

我不知道 $request->get() 是如何解析的,因為 IlluminateHttpRequest 中沒有函數名稱 get().input() 和 get() 做同樣的事情.

I have no idea how $request->get() is resolving as there is no function name get() in IlluminateHttpRequest. input() and get() does the same thing.

方法注入是否比使用 Facades 更好?

Is method injection better than using Facades?

推薦答案

在控制器方法中請求注入功能總是更可取的,因為在某些方法中它可以幫助您使用表單請求(它們擴展默認請求類)驗證,即將在進入實際控制器方法之前自動驗證您的請求.這是一個很棒的功能,有助于創建纖薄和干凈的控制器代碼.

In controller method Request injection functionality is always preferable, because in some methods it could help you to use Form Requests (they are extending default Request class) validation, that will validate your request automatically just before entering to the actual controller method. This is an awesome feature that helps to create slim and clean controller's code.

使用默認請求注入使您的控制器方法相似且更易于維護.

Using default Request injection makes your controller's methods similar and easier to maintain.

還有對象注入總是比 Facades 好,因為這樣的方法 &對象更容易測試.

Also object injection is always better than Facades, because such methods & objects are easier to test.

get()input() 是不同類的方法.第一個是Symfony HttpFoundation Request的方法,input()是繼承Symfony Request類的Laravel Request類的方法.

get() andinput() are methods of different classes. First one is method of Symfony HttpFoundation Request, input() is a method of the Laravel Request class that is extending Symfony Request class.

這篇關于Laravel 請求 input() 或 get()的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Laravel Eloquent Union query(Laravel Eloquent Union 查詢)
Overwrite laravel 5 helper function(覆蓋 Laravel 5 輔助函數)
laravel querybuilder how to use like in wherein function(laravel querybuilder 如何在 where 函數中使用 like)
The Response content must be a string or object implementing __toString(), quot;booleanquot; given after move to psql(響應內容必須是實現 __toString()、“boolean和“boolean的字符串或對象.移動到 psql 后給出) - IT屋-程
Roles with laravel 5, how to allow only admin access to some root(Laravel 5 的角色,如何只允許管理員訪問某些根)
Laravel Auth - use md5 instead of the integrated Hash::make()(Laravel Auth - 使用 md5 而不是集成的 Hash::make())
主站蜘蛛池模板: 成人性视频免费网站 | 亚洲码欧美码一区二区三区 | 国产99免费 | 国产丝袜av | 中文字幕亚洲视频 | 久久久综合久久 | 在线播放精品视频 | 久久亚洲国产精品 | 日韩中文字幕在线观看 | 欧美精品首页 | 精品久久久久久久人人人人传媒 | 伊人超碰 | 国产免费拔擦拔擦8x高清 | 国产精品久久久久久久久久妞妞 | 欧美成人在线网站 | 精品国产乱码久久久久久老虎 | 亚洲444eee在线观看 | 亚洲精品黄色 | 国产精品国产精品 | 九九综合 | 成人在线观看免费 | 欧美一级大片免费看 | 国产精品一区二区在线 | 午夜激情在线视频 | 日韩国产欧美在线观看 | 亚洲一区在线播放 | 色接久久 | 亚洲一区二区三区在线播放 | 91精品亚洲 | 激情欧美一区二区三区 | 97久久精品午夜一区二区 | 国产香蕉视频在线播放 | 九色av| 国产一区二区在线视频 | 亚洲自拍偷拍av | 久久国产精品一区二区三区 | 天天天堂| www.色综合| 成人av网站在线观看 | 国产精品免费看 | 日韩欧美亚洲 |