'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'enableStrictParsing' => true, //строго следовать правилам, будут работать только те url, которые заданы в rules
'rules' => [
// GET /car -> baseController -> actionIndex
'<type:(car|bike)>' => 'base/index',
// GET /car/<action> -> baseController -> action<action>,
// Например GET /car/create -> baseController -> actionCreate,
// Можно так же задать ч/з regex список action
// '<type:(car|bike)>/<action:(create|update|delete)>' => 'base/<action>',
'<type:(car|bike)>/<action:\w+>' => 'base/<action>',
]
],
//Передаем тип в нужные экшены
public function actionIndex($type)
{
return $type; // car || bike
}
'rules' => [
'/' => 'site/index',
[
'pattern' => '<type:(car|bike)>',
'route' => 'base/index',
//'suffix' => '.html', //добавлять suffix к концу url - Например: /car.html,
//'defaults' => ['type' => 'car'], //Значения по-умолчанию
],
],
'/<type:(car|bike)>' => 'base/index'
SELECT c.*
FROM Table1 AS c
JOIN ( SELECT city, COUNT(*) AS cnt
FROM Table1
GROUP BY city
) AS c2 ON ( c2.city = c.city )
ORDER BY c2.cnt DESC, c.name ASC;
function schedule() {
$data = '{"07:10":["\u0423\u0442\u0440\u043e","http:\/\/vue.by\/wp-content\/uploads\/2018\/10\/2.jpg"],"07:12":["\u041f\u0440\u0438\u0432\u0435\u0442\u044b","http:\/\/vue.by\/wp-content\/uploads\/2018\/10\/4.jpg"],"08:10":["\u0423\u0442\u0440\u043e","http:\/\/vue.by\/wp-content\/uploads\/2018\/10\/2.jpg"],"08:19":["\u041f\u0440\u0438\u0432\u0435\u0442\u044b","http:\/\/vue.by\/wp-content\/uploads\/2018\/10\/4.jpg"],"09:19":["\u0417\u0432\u0435\u0437\u0434\u0430","http:\/\/vue.by\/wp-content\/uploads\/2018\/10\/1-1.jpg"],"10:15":["\u0423\u0442\u0440\u043e","http:\/\/vue.by\/wp-content\/uploads\/2018\/10\/2.jpg"],"10:35":["\u041f\u0440\u0438\u0432\u0435\u0442\u044b","http:\/\/vue.by\/wp-content\/uploads\/2018\/10\/4.jpg"],"11:46":["\u0423\u0442\u0440\u043e","http:\/\/vue.by\/wp-content\/uploads\/2018\/10\/2.jpg"],"11:56":["\u041f\u0440\u0438\u0432\u0435\u0442\u044b","http:\/\/vue.by\/wp-content\/uploads\/2018\/10\/4.jpg"],"12:42":["\u0417\u0432\u0435\u0437\u0434\u0430","http:\/\/vue.by\/wp-content\/uploads\/2018\/10\/1-1.jpg"],"14:00":["\u0423\u0442\u0440\u043e","http:\/\/vue.by\/wp-content\/uploads\/2018\/10\/2.jpg"],"18:49":["\u0417\u0432\u0435\u0437\u0434\u0430","http:\/\/vue.by\/wp-content\/uploads\/2018\/10\/1-1.jpg"]}';
return json_decode($data, true);
}
function closestTime() {
date_default_timezone_set('Europe/Moscow');
$currentTime = date( "H:i" );
$list = schedule();
ksort($list);
$first = key($list);
$prev = $first;
$currentTime = '18:48';
foreach ( $list as $key => $val ) {
if ( $currentTime >= $key ) {
$prev = $key;
continue;
}
return json_encode( $list[$prev] );
}
return json_encode( end($list) );
}