AH
->when($ids, function($query, $ids) {
return $query->whereIn('id', $ids);
})
https://laravel.com/docs/6.x/queries#conditional-clauses
Size: a a a
AH
->when($ids, function($query, $ids) {
return $query->whereIn('id', $ids);
})
MG
@includeIf('news.templates.part_with_element_'.$news->count())
То есть есть шаблоны, например, 1, 2, 3, 4, ..., n+1 ?MG
AH
->when($ids, function($query, $ids) {
return $query->whereIn('id', $ids);
})
ИС
AH
ИС
ИС
AH
AH
Sometimes you may want clauses to apply to a query only when something else is true. For instance you may only want to apply a where statement if a given input value is present on the incoming request. You may accomplish this using the when method:
Иногда вам нужно, чтобы условия применялись только когда что-то является истинным (true).
Например, вам нужно применять оператор where только в том случае, если во входящем запросе присутствует заданное значение. Вы можете сделать это используя метод when:
AH
Sometimes you may want clauses to apply to a query only when something else is true. For instance you may only want to apply a where statement if a given input value is present on the incoming request. You may accomplish this using the when method:
Иногда вам нужно, чтобы условия применялись только когда что-то является истинным (true).
Например, вам нужно применять оператор where только в том случае, если во входящем запросе присутствует заданное значение. Вы можете сделать это используя метод when:
AH
AH
php
$value1 = '15';
$value2 = 0;
return $value1 ? 'y' : 'n'; // вернет y
return (int) $value1 ? 'y' : 'n'; // вернет y
return $value2 ? 'y' : 'n'; // вернет n
return (int) $value2 ? 'y' : 'n'; // вернет n
AH
$documentTypes = $request->documentTypes ?? false;
AH
$documentTypes = $request->documentTypes ?? false;
$documentTypes = $request->get('documentTypes', false);
AH
$documentTypes = $request->get('documentTypes', false);
AH
AH
$request->get()
, кто-то - $request->input()
.ИС
$documentTypes = $request->documentTypes ?? false;
AH
$request->get()
, кто-то - $request->input()
.