function getNoun(number, one, two, five) {
let n = Math.abs(number);
n %= 100;
if (n >= 5 && n <= 20) {
return five;
}
n %= 10;
if (n === 1) {
return one;
}
if (n >= 2 && n <= 4) {
return two;
}
return five;
}
alert("4 " + getNoun(4, 'слон', 'слона', 'слонов'));
async..await
равносильно throw
catch
.v.0.22.0
SELECT
s.*,
CONCAT(u.name, ' ', s.house_number) as address
FROM
users u
LEFT JOIN streets s ON s.id = u.street_id
WHERE u.full_name LIKE '%на%'
OR CONCAT(u.name, ' ', s.house_number) LIKE '%на%'
LIMIT 0, 10
public function scopeOfSearch(Builder $query, $search){
return $query->leftjoin('streets', 'streets.id', '=', 'users.street_id')->where(function($builder) use($search){
return $query->whereRaw('CONCAT(u.name, ' ', s.house_number) like ?', '%'.$search.'%')->orWhere('users.full_name', 'like', '%'.$search.'%');
});
}
$users = User::ofSearch($search)->paginate(10);
return [
['full_name', 'contacts'],
['', 'type', 'name',],
];
$sheet->mergeCells('A1:B1');
$schedule->command('my:command')->cron('*/7 07-22 * * *');
public function expose() {
return array_map(fn($n) => $n instanceof Text ? $n->expose() : $n, get_object_vars($this));
}
SELECT
t.str,
SUM(n)
FROM (
(SELECT str1 as str, COUNT(*) as n FROM tableName WHERE date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY str1)
UNION
(SELECT str2 as str, COUNT(*) as n FROM tableName WHERE date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY str2)
) as t
GROUP BY t.str