从laravel 5.4中的刀片模板中的数据库中获取价值

时间:2018-02-11 06:59:26

标签: laravel-5 laravel-5.3

这里我想从数据库中获取价值。我在布局中使用它,我不想使用控制器来获取价值。它没有显示任何东西。我该如何解决?提前谢谢

info.blade.php

{{$data = \App\visitor::where('flag',1)->get()}}

    @foreach ($data as $val)
       Name  {{ $val->v_name }} <br>
       Mobile  {{ $val->v_mobile }}
     @endforeach

1 个答案:

答案 0 :(得分:1)

即使不使用控制器也不是一个好主意,你可以这样做

def currency_converter(amount):
  amount = int(100*amount)
  hundred = (amount//10000)
  amount -= hundred*10000
  fifty = (amount//5000)
  amount -= fifty*5000
  ten = (amount//1000)
  amount -= ten*1000
  five = (amount//500)
  amount -= five*500
  one = (amount//100)
  amount -= one*100
  quarter = (amount//25)
  amount -= quarter*25
  dime = (amount//5)
  amount -= dime*5
  penny = amount
  return (hundred, fifty, ten, five, one, quarter, dime,penny)