1

I have a field called "menuIds" in "menu-permissions" table where the data looks like this--

[{"id":1,"menuName":"service","code":"1"},
{"id":2,"menuName":"food","code":"3"},
{"id":3,"menuName":"cloths","code":"hfuiu"},
{"id":4,"menuName":"Geoffrey","code":pr"}]

controller--

public function log()
    {
        $menuPermissions = MenuPermission::all();
        return view('master.dashboard',compact('menuPermissions'));
    }

How do I Show only the menuNames in a list?

the table looks like this menu-permissions table

1 Answer 1

2

I guess you are using Laravel Blade, if that's the case you can use below code

@foreach($menuPermissions as $menuPermission)   
   @foreach(json_decode($menuPermission->menuids) as $ids)   
      {{$ids->menuName}}
   @endforeach 

@endforeach 
Sign up to request clarification or add additional context in comments.

8 Comments

I have updated the question. Please check now
do you mean menuIds Table ?
No. Table name is "menu-permissions". there is a field called "menuIds" which look like that
simple you just chnage filed name as shown above like $menuPermission->menuIds
But then I get the whole array. I just want the "menuName"
|

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.