моя база данных
Код: Выделить всё
--------------------------------------
id name view created_at
--------------------------------------
1 one 9 2021-01-13 12:34:22
2 two 8 2021-01-15 10:23:02
3 three 23 2021-01-15 20:55:17
4 forth 15 2021-01-16 12:34:22
5 fifth 0 2021-01-19 10:37:02
Код: Выделить всё
--------------------------------------
id name view created_at
--------------------------------------
5 fifth 0 2021-01-19 10:37:02
3 three 23 2021-01-15 20:55:17
4 forth 15 2021-01-16 12:34:22
1 one 9 2021-01-13 12:34:22
2 two 8 2021-01-15 10:23:02
Код: Выделить всё
$today = '2021-01-19'; //this date will calculate in daily. Not absolute date!
$firstarray=Product::where('created_at','LIKE',$today.'%')->get();
$secondarray=Product::orderBy('viewer', 'DESC')->get();
$data = array_merge($firstarray,$secondarray);
return $data;
Код: Выделить всё
$today = '2021-01-19'; //this date will calculate in daily. Not absolute date!
$data = Product::orderBy(DB::raw('FIELD(created_at, LIKE $today."%")'),'DESC')
->orderBy('view','desc')->get();
return $data;
Извините за мои знания английского языка
спасибо всем
Подробнее здесь: https://stackoverflow.com/questions/657 ... assing-var