// Кэширование запросов для DAO
// Возвращает ассоциативный массив с именами столбцов и значений
$categories = Yii::$app->db->cache(function () {
return Yii::$app->db->createCommand('SELECT * FROM `category`')->queryAll();
});
// Кэширование запросов для ActiveRecord (на 1 час)
// Возвращает объект
$categories = Category::getDb()->cache(function (){
return Category::find()->all();
}, 3600);
BaseOAuth::defaultReturnUrl() doesn't specify protocol. It means return URL generated matches protocol used at the website. If your website is served via HTTP it doesn't make sense to set return URL to HTTPS.
<?= $form->field($model, 'category_at')->widget(DatePicker::class, [
'options' => ['placeholder' => 'ДД.MM.ГГГГ'],
'pluginOptions' => [
'todayHighlight' => true,
'todayBtn' => true,
'autoclose' => true,
'format' => 'dd.mm.yyyy',
'startView' => 'months',//'startDate' => date('d.m.Y'),
],
]); ?>
['datetime', 'date', 'format' => 'php:d.m.Y']
Есть ли смысл использовать тригеры и есть ли прирост от этого, а может и наоборот?
$widgetClass = $widgetConfig['class'];
if (!(is_subclass_of($widgetClass, AuthChoiceItem::AuthChoice))) {
throw new InvalidConfigException('Item widget class must be subclass of "' . AuthChoiceItem::AuthChoice . '"');
}
AuthChoiceItem::class
class Controller
{
private $repo;
pulic function __construct(MissionRepository $repo)
{
$this->repo = $repo;
}
pulic function excuteMission($id)
{
$mission = $this->repo->find($id);
$mission->next();
$mission->save();
}
}
class Mission
{
private $progress;
public function next(): void
{
$progress = $this->progress + 10;
if($progress > 100) {
throw new DomainExeption('Миссия не может быть выполнена.')
}
if($progress = 100) {
throw new DomainExeption('Миссия уже выполнена.')
}
}
}