Skip to content

Instantly share code, notes, and snippets.

@Mopkau
Mopkau / gist:7cd5f846bb547fd475ba5b5f39965fa4
Created July 29, 2016 16:28
Таблица "Новости по категориям"
public function safeUp()
{
$tableOptions = null;
if ($this->db->driverName === 'mysql') {
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
}
$this->createTable('{{%article_category}}', [
'id' => $this->primaryKey(),
'slug' => $this->string(1024)->notNull(),
'title' => $this->string(512)->notNull(),
@Mopkau
Mopkau / gist:cab84215ab4f4c5c3b6bb36e6919a4a9
Created July 29, 2016 16:27
Миграция "Страницы"
public function up()
{
$tableOptions = null;
if ($this->db->driverName === 'mysql') {
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
}
$this->createTable('{{%page}}', [
'id' => $this->primaryKey(),
'slug' => $this->string(2048)->notNull(),
'title' => $this->string(512)->notNull(),
public function registerClientScript()
{
UploadAsset::register($this->getView());
$options = Json::encode($this->clientOptions);
if ($this->sortable) {
JuiAsset::register($this->getView());
}
$this->getView()->registerJs("jQuery('#{$this->getId()}').yiiUploadKit({$options});");
}
public function loadModel($id, $class = false, $attributes = false, $prepare = true, $seo = true, $condition = '', $params = array())
{
if ($class === false) {
$class = $this->getModelClass();
}
/** @var ActiveRecord $finder */
$finder = ActiveRecord::model($class)->published();
if (is_array($id) && $attributes) {
$model = $finder->findByAttributes($id, $condition, $params);
} else {
@Mopkau
Mopkau / ActiveFormClear
Created July 5, 2016 11:40
Yii2 ActiveForm with ClearActiveInput
<?php
$form = ActiveForm::begin(
[
'id' => '',
'fieldClass'=>ClearActiveField::className()]
@Mopkau
Mopkau / gist:c5b8d439a4540ea1bf1fffa16b0c5d5e
Created July 5, 2016 11:37
Add .gitignore in existing project
git rm -r --cached .
git add *
git commit -m "add .gitignore"