Англоязычные ресурсы:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function behaviors() | |
{ | |
return [ | |
'timestamp' => [ | |
'class' => 'yii\behaviors\TimestampBehavior', | |
'attributes' => [ | |
\yii\db\ActiveRecord::EVENT_BEFORE_INSERT => ['date_create', 'date_update'], | |
\yii\db\ActiveRecord::EVENT_BEFORE_UPDATE => ['date_update'], | |
], | |
], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
&НаКлиенте | |
Функция РассчитатьПроцентНаценки(ЦенаЗакупки, ЦенаПродажи) | |
ПроцентНаценки = 0; | |
Если ЦенаЗакупки <> 0 Тогда | |
ПроцентНаценки = (ЦенаПродажи - ЦенаЗакупки) * 100 / ЦенаЗакупки; | |
КонецЕсли; | |
Возврат ПроцентНаценки; | |
КонецФункции |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Сомневался в добавлении этого в статью. Добавлю комментом. Обычно делаем через таблицу связей. Типичный пример для блога и постов. | |
Таблица post(модель Post) — храним метаинформацию, которая не имеет отношения к контенту. | |
То есть такие поля: id, owner_id, date_create, date_update. | |
Таблица post_lang(модель PostLang) — связь контента по языкам. Поля: id, post_id, lang_id, name, description. | |
Соответственно поля post_id — это id из таблицы post, lang_id — это id из таблицы lang. name и | |
description — контент на соответствующем языке. | |
В модель Post добавляем отношение: | |
public function getContent($lang_id=null) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Basic package | |
Options +FollowSymLinks | |
IndexIgnore */* | |
RewriteEngine on | |
# Если запрос не начинается с web, добавляем его | |
RewriteCond %{REQUEST_URI} !^/(web) | |
RewriteRule (.*) /web/$1 | |
# Если файл или каталог не существует, идём к /web/index.php |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create method in your model class | |
public function getManyToManyTableName($relationName) | |
{ | |
$string = ''; | |
$array = $this->$relationName; | |
if(empty($array)) { | |
return Yii::t('app', 'Not set'); | |
} | |
$arrayLength = count($array); | |
$counter = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# JetBrains IDE | |
.idea | |
# Windows thumbnail cache | |
Thumbs.db | |
desktop.ini | |
debug.log | |
# Mac DS_Store Files | |
*.DS_Store |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Application requirement checker script. | |
* | |
* In order to run this script use the following console command: | |
* php requirements.php | |
* | |
* In order to run this script from the web, you should copy it to the web root. | |
* If you are using Linux you can create a hard link instead, using the following command: | |
* ln requirements.php ../requirements.php |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
server_name laravel.loc; | |
root /vagrant/www/laravel.loc/public; | |
index index.php index.html index.htm; | |
location / { | |
try_files $uri $uri/ /index.php?$query_string; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Recursively changes the first character register of all keys in an array. | |
* @param array $array The array to work on | |
* @param int $case Either CASE_UPPER or CASE_LOWER (default) | |
* @return array Returns an array with its keys lower or uppercase. | |
* | |
* Inspired by http://php.net/manual/en/function.array-change-key-case.php | |
* @author Grigory Alexandrov <[email protected]> |
OlderNewer