我想在刀片中获取配置值。
config/define.php
<?php
return [
'show' => array(1 => 'Show',0 => 'Hide' ),
];
Run Code Online (Sandbox Code Playgroud)
我找到了一个代码
{{ Config::get('define.show') }}
Run Code Online (Sandbox Code Playgroud)
但我想使用:
{{ $showarray = Config::get('define.show') }}
@foreach ($master as $pt)
{{ $showarray[$pt->show_flag] }}
@endforeach
Run Code Online (Sandbox Code Playgroud)
但它不起作用。请帮帮我!
我有这个代码:
$result = DB::table('product as p')
->join('master as cl', 'p.color', '=', 'cl.name')
->join('master as brand', 'p.brand', '=', 'brand.name')
->where('p.brand', $brandname)
->whereRaw("p.del_flag = 0 and cl.is_active = 1 and brand.is_active = 1 and p.product_type = 1")
->select('p.name')
->groupBy('p.name')
->orderBy('p.name')
->take(3)
->get();
Run Code Online (Sandbox Code Playgroud)
我需要添加过滤器:
if(isset($_POST['brand'])) {
->where('p.brand', $_POST['brand'])
}
if(isset($_POST['color'])) {
->where('p.color', $_POST['color'])
}
if(isset($_POST['product_type'])) {
->where('p.product_type', $_POST['product_type'])
}
Run Code Online (Sandbox Code Playgroud)
我看过很多关于 Laravel 中多个Where 的帖子,但没有一篇讨论那些特殊的Where。
如何在查询中添加过滤器?