如何检查Laravel 5.2中的URL?

时间:2016-05-24 07:15:18

标签: php html css laravel

我在Laravel中创建并隐藏了某个导航。导航使用导航标记

这是我目前的代码:

@if (Request::url() === 'login')
    <nav></nav>
@endif

问题:我只希望标签出现在LOGIN页面中。

请帮我修复上面的代码。任何帮助表示赞赏。

3 个答案:

答案 0 :(得分:2)

这应该适用于您的代码。

Public Sub SaveAtmt_ExportToExcel(Item As Outlook.MailItem) Dim Atmt As Outlook.Attachment Dim SaveFolder As String Dim DateFormat As String Dim strID As String, olNS As Outlook.NameSpace Dim olMail As Outlook.MailItem Dim strFileName As String '~~> Excel Variables Dim oXLApp As Object, oXLwb As Object, oXLws As Object Dim lRow As Long Dim i As Long SaveFolder = "c:\temp\" DateFormat = Format(Now, "yyyy-mm-dd H mm") For Each Atmt In Item.Attachments Atmt.SaveAsFile SaveFolder & "\" & DateFormat & " " & Atmt.DisplayName Next strID = Item.EntryID Set olNS = Application.GetNamespace("MAPI") Set olMail = olNS.GetItemFromID(strID) '~~> Establish an EXCEL application object On Error Resume Next Set oXLApp = GetObject(, "Excel.Application") '~~> If not found then create new instance If Err.Number <> 0 Then Set oXLApp = CreateObject("Excel.Application") End If Err.Clear On Error GoTo 0 '~~> Show Excel oXLApp.Visible = True '~~> Open the relevant file Set oXLwb = oXLApp.Workbooks.Open("C:\Temp\Book1.xlsx") '~~> Set the relevant output sheet. Change as applicable Set oXLws = oXLwb.Sheets("Multiplier") lRow = oXLws.Range("A" & oXLws.Rows.Count).End(xlUp).Row + 1 '~~> Write to outlook With oXLws lRow = .Range("A" & .Rows.Count).End(xlUp).Row + 1 Dim MyAr() As String MyAr = Split(olMail.body, vbCrLf) For i = LBound(MyAr) To UBound(MyAr) .Range("A" & lRow).Value = MyAr(i) lRow = lRow + 1 Next i ' End With '~~> Close and Clean oXLwb.Close (True) oXLApp.Quit Set oXLws = Nothing Set oXLwb = Nothing Set oXLApp = Nothing Set olMail = Nothing Set olNS = Nothing Set Atmt = Nothing End Sub

! means IS NOT.

因此,当网址不是“登录”时,此代码就会运行。

您也可以使用@if (!Request::url() === 'login') <nav></nav> @endif 。 (https://laravel.com/docs/5.2/routing#named-routes

named routes

您可以检查该页面是否为Route::get('login', ['as' => 'login', 'uses' => 'ControllerName@methodName']); 。你可以这样做:

login

希望这有效!

答案 1 :(得分:0)

按如下方式制作您的登录路线:

Route::get('login', ['as' => 'login', 'uses' => 'ControllerName@methodName']);

现在在视图页面上执行以下操作:

@if(Route::is('login'))
  <nav></nav>
@endif

这将显示&#39; nav&#39;路由未登录时标记 希望这会对你有所帮助。

答案 2 :(得分:0)

这应该可以解决问题:

&#39;!&#39;表示NOT,因此导航会在网址未登录时显示。

@if (!Request::is('login')) 
        <nav>I Am a menu item</nav>
@endif