Skip to content
Advertisement

How to hide a div if a value from db matches – Laravel

I want to hide a <div> element if the value is_admin === "0" in table admins.

Here is my Controller Code

    function dashboard(Request $request){
    $data = ['LoggedUserInfo'=>Admin::where('id','=', session('LoggedUser'))->first()];
    $count = DB::table('candidates')->count();
    $count2 = DB::table('admins')->count();

    $data1 = DB::table('admins');
    $data1 = $data1->paginate(10);


    return view('dashboard', $data,compact('count','count2','data1'));
}

I want to hide this div if is_admin === "0"

<div class="c1" id="l1">
<div class="container">
<div class="card">
  <p class="p">No. of Candidates: {{$count}}</p>
</div>
<div class="card">
  <p class="p">No. of Sub Admins: {{$count2}}</p>
 </div>
</div>
</div>

Advertisement

Answer

@if($is_admin !== '0')
  <div class="c1" id="l1">
    <div class="container">
      <div class="card">
        <p class="p">No. of Candidates: {{$count}}</p>
      </div>
      <div class="card">
         <p class="p">No. of Sub Admins: {{$count2}}</p>
      </div>
    </div>
  </div>
@endif
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement