You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在「管理商户ID」视图中显示全名而非商户ID

Alright, let's get this sorted out for you. Here's a step-by-step solution to replace the $merchantId display with the fullname from your database:

Step 1: Update the SubMerchantController to Fetch the Fullname

First, you need to retrieve the corresponding SubMerchant record from your database using the $merchantId parameter, then pass the fullname (or the entire model instance) to your view.

Assuming you have a method in your SubMerchantController that handles this view (like show() or edit()), update it like this:

public function show($merchantId)
{
    // Fetch the SubMerchant record using the merchantId
    // Adjust the column name if your merchant ID field is named differently (e.g., id)
    $subMerchant = SubMerchant::where('merchantId', $merchantId)->firstOrFail();
    
    // Pass both the merchantId (if you still need it elsewhere) and the subMerchant instance to the view
    return view('your-view-path-here', compact('merchantId', 'subMerchant'));
}

Note: Replace your-view-path-here with the actual path to your view file (e.g., submerchants.manage).

Step 2: Modify the View to Display the Fullname

Now update your view code to replace $merchantId with the fullname from the fetched SubMerchant instance. I also fixed a missing closing tag on the <i> element to avoid frontend issues:

<div class="content-header-left col-md-6 col-12 mb-1">
    <h3 class="content-header-title mb-0 font-14">
        <a href="#">
            <i class="close icon-arrow-left font-16 px-50 float-left"></i>
        </a>
        Manage <?php echo $subMerchant->fullname; ?>
    </h3>
</div>

If you prefer using Blade syntax (since this looks like a Laravel project), you can write {{ $subMerchant->fullname }} instead of <?php echo ... ?> for cleaner code.

Quick Checks

  • Make sure your SubMerchant model has the fullname field included in its $fillable property (if you're using mass assignment) or that it's not guarded.
  • Verify that the merchantId parameter passed to the controller method matches the column name in your database table.

内容的提问来源于stack exchange,提问作者Alok Srivastava

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.06 17:19:10