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

Laravel 請求 input() 或 get()

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

問題描述

在 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');
    }
}

我有幾個(gè)問題:

使用 IlluminateHttpRequest 比使用 IlluminateSupportFacadesRequest

我不知道 $request->get() 是如何解析的,因?yàn)?IlluminateHttpRequest 中沒有函數(shù)名稱 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?

推薦答案

在控制器方法中請求注入功能總是更可取的,因?yàn)樵谀承┓椒ㄖ兴梢詭椭褂帽韱握埱?它們擴(kuò)展默認(rèn)請求類)驗(yàn)證,即將在進(jìn)入實(shí)際控制器方法之前自動(dòng)驗(yàn)證您的請求.這是一個(gè)很棒的功能,有助于創(chuàng)建纖薄和干凈的控制器代碼.

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.

使用默認(rèn)請求注入使您的控制器方法相似且更易于維護(hù).

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

還有對象注入總是比 Facades 好,因?yàn)檫@樣的方法 &對象更容易測試.

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

get()input() 是不同類的方法.第一個(gè)是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.

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

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

相關(guān)文檔推薦

Laravel Eloquent Union query(Laravel Eloquent Union 查詢)
Overwrite laravel 5 helper function(覆蓋 Laravel 5 輔助函數(shù))
laravel querybuilder how to use like in wherein function(laravel querybuilder 如何在 where 函數(shù)中使用 like)
The Response content must be a string or object implementing __toString(), quot;booleanquot; given after move to psql(響應(yīng)內(nèi)容必須是實(shí)現(xiàn) __toString()、“boolean和“boolean的字符串或?qū)ο?移動(dòng)到 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())
主站蜘蛛池模板: 欧美午夜一区二区三区免费大片 | 国产高清在线视频 | 国产片侵犯亲女视频播放 | 午夜精品导航 | 久久久久亚洲精品 | 日韩在线一区二区 | 国产精品久久久久久久久久久新郎 | 国产一区二区三区在线视频 | 亚洲综合色视频在线观看 | 精品一区二区三区中文字幕 | 羞羞视频在线观看免费观看 | 亚洲欧美一区二区三区国产精品 | 免费的av| 欧美视频一区 | 日韩欧美在线免费观看 | 亚洲激情在线视频 | 毛片免费观看 | 人人种亚洲| 欧美精品一区二区三区在线 | 久久久久久天堂 | 精品欧美一区二区三区免费观看 | 毛片久久久 | 日韩电影中文字幕 | 国产在线一区观看 | 91精品国产一区 | 一区二区三区四区国产 | 国产精品中文 | 日操夜操 | 夜夜爽夜夜操 | 欧美性jizz18性欧美 | 免费观看黄a一级视频 | 中文字幕一区二区三区四区 | 性国产xxxx乳高跟 | jav成人av免费播放 | 精品国产视频在线观看 | 日韩欧美一级精品久久 | 日韩中文字幕 | 亚洲www. | 欧美精品一区二区三区四区五区 | 日本一二区视频 | 日韩一区二区久久 |