久久久久久久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())
主站蜘蛛池模板: 一区二区三区久久久 | 在线精品一区 | 黄色成人在线视频 | 精品一区二区三区四区五区 | 欧美精品二区三区四区免费看视频 | 欧美国产在线视频 | 亚洲国产欧美日韩在线 | 国产午夜在线观看 | 一级毛片在线免费观看 | 国产美女永久免费无遮挡 | 激情网站在线观看 | 国产久 | 另类一区二区 | 国产成人免费视频 | 涩涩在线| av福利在线| 日本男人天堂 | 男女激情视频网站 | av久草| 中文字幕专区 | 久久国产成人 | 国产一区在线视频 | av在线小说| 黄色1级视频 | 国产精品成人免费一区久久羞羞 | avtt久久| 国产在线成人 | 黄色免费毛片 | 在线播放亚洲 | 久久激情视频 | 欧美一级全黄 | 欧美在线一级 | 亚洲美女爱爱 | 午夜视频在线免费观看 | 老司机免费福利视频 | 福利视频网站 | 成人动漫在线观看 | 91美女网站 | 午夜视频在线看 | 高潮毛片无遮挡免费看 | 在线观看日本 |