我有四个步骤。每个步骤的网址都是 -
基本信息:localhost/project/public/user/sell/basic-info
产品信息:localhost/project/public/user/sell/5/product-info
照片:localhost/project/public/user/sell/5/photos
价格信息:localhost/project/public/user/sell/5/price-info
我想,当我在basic-info时,基本信息步骤必须有active
类,其余步骤将有disabled
类。
当我处于product-info时,基本信息步骤将没有任何类,产品信息步骤将有active
类,其后的其余步骤将disabled
上课等等。
下面是图片。
这是我的代码 -
<div class="ui mini top four attached steps">
<div class="{{ Request::segment(3) === 'basic-info' ? 'active' : '' }} step">
<i class="info circle icon"></i>
<div class="content">
<div class="title">Basic Info</div>
<div class="description">Enter the basic information.</div>
</div>
</div>
<div class="{{ Request::segment(4) === 'product-info' ? 'active' : Request::segment(3) === 'basic-info' ? 'disabled' : '' }} step">
<i class="help circle icon"></i>
<div class="content">
<div class="title">Product Info</div>
<div class="description">Enter your product details.</div>
</div>
</div>
<div class="{{ Request::segment(4) === 'photos' ? 'active' : Request::segment(3) === 'basic-info' ? 'disabled' : Request::segment(4) === 'basic-info' ? 'disabled' : '' }} step">
<i class="image icon"></i>
<div class="content">
<div class="title">Photos</div>
<div class="description">Upload the photos of product.</div>
</div>
</div>
<div class="{{ Request::segment(4) === 'price-info' ? 'active' : Request::segment(3) === 'basic-info' ? 'disabled' : Request::segment(4) === 'basic-info' ? 'disabled' : Request::segment(4) === 'basic-info' ? 'disabled' : '' }} step">
<i class="rupee icon"></i>
<div class="content">
<div class="title">Price</div>
<div class="description">Enter the price</div>
</div>
</div>
</div>
答案 0 :(得分:0)
我建议为此事创建一个帮助函数。
以下是我在一个应用中使用的内容:
<?php
namespace App\Helpers;
use Route;
class Helper
{
/*
|--------------------------------------------------------------------------
| Detect Active Route
|--------------------------------------------------------------------------
|
| Compare given route with current route and return output if they match.
| Very useful for navigation, marking if the link is active.
|
*/
public static function isActiveRoute($route, $output = "active")
{
if (Route::currentRouteName() == $route) return $output;
}
}
在config\app.php
注册课程和Helper
'Helper' => App\Helpers\Helper::class, //my custom functions
然后您可以像以下一样使用它:
class="{{ Helper::isActiveRoute('route.name') }}"