0

This is my code

<?php

namespace App\Http\ViewComposers;

use Illuminate\View\View;
use Auth;

class SideNavDeliGroceryComposer
{
    /**
     * Bind data to the view.
     *
     * @param  View  $view
     * @return void
     */
    public function compose(View $view)
    {
        $navigations = [
            'dashboard' => [
                'title' => 'Dashboard',
                'url' => 'deligrocery.dashboard.view',
                'icon' => 'delirush-am-dashboard',
                'permission_for' => 'dashboard'
            ],
            'customers' => [
                [
                    'title' => 'Customers',
                    'url' => 'deligrocery.customer.view',
                    'icon' => 'delirush-am-customers',
                    'permission_for' => 'customer'
                ], [
                    'title' => 'Orders',
                    'url' => 'deligrocery.customer.order-management.view',
                    'icon' => 'delirush-am-orders',
                    'permission_for' => 'order'
                ]
            ],
            'delivery' => [
                [
                    'title' => 'Rushers',
                    'url' => 'deligrocery.delivery.rusher.view',
                    'icon' => 'delirush-am-rushers',
                    'permission_for' => 'rusher'
                ], [
                    'title' => 'Job Order Management',
                    'url' => 'deligrocery.delivery.job-order.view',
                    'icon' => 'delirush-am-delivery',
                    'permission_for' => 'job-order'
                ]
            ],
            'grocery_partner' => [
                [
                    'title' => 'Partner Management',
                    'url' => 'deligrocery.grocery-partner.partner-manager.view',
                    'icon' => 'fa-solid fa-store',
                    // 'icon' => 'delirush-am-food-partners',
                    'permission_for' => 'rusher'
                    
                ]
            ],
            'service_settings' => [
                [
                    'title' => 'Delivery Service Configuration',
                    'url' => 'deligrocery.delivery_service_settings.view',
                    'icon' => 'delirush-am-delivery-fee',
                    'permission_for' => 'delivery-service-configuration'
                ]
            ],
            'finance' => [
                [
                    'title' => 'Finance Management',
                    'url' => 'deligrocery.finance.merchant-partner-commission-report.view',
                    'icon' => 'delirush-am-finance',
                    'permission_for' => 'finance'
                ]
            ],
            'Tools' => [
                [
                    'title' => 'Category Type Management',
                    'url' => 'deligrocery.tools.category-type.view',
                    'icon' => 'delirush-am-finance',
                    'permission_for' => 'finance'
                ]
            ],
        ];
        
        // $navs = ['customers' => [],'delivery' => []];
        // $permissions = Auth::guard('admin')->user()->getAllPermissions()->groupBy('permission_for');
        // foreach ($permissions as $permissionKey => $permission) {
        //     foreach($navigations as $navKey => $navigation) {
        //         $permissionFors = array_column($navigation, 'permission_for');
        //         $check = array_search($permissionKey, $permissionFors);
        //         if($check !== false) {
        //             array_push($navs[$navKey], $navigation[$check]);
        //         }
        //     }
        // }
        
        $view->with([
            'navs' => $navigations,
            'current' => request()->route()->getName()
        ]);
    }
}

I want to put this code <i class="fa-solid fa-store"></i> inside array in 'icon' label

2
  • I want to put this html code inside the array icon <i class="fa-solid fa-store"></i> Commented Mar 14, 2022 at 3:52
  • You can simply write html there if you want, if you have encoding problem while rendering then bypass html encode of blade file. Commented Mar 14, 2022 at 4:27

1 Answer 1

2

You can put that html code in the array and then when you render it in the blade file you will need to escape it so it displays as html, you can do so like this:

{!! $icon !!}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.