View FindOrCreate.php
<?php
use Yii;
use yii\base\Exception;
trait FindOrCreate
{
/**
* @param int|string $pk
* @return static
View telegram icon.txt
To convert this svg to web font – just upload `telegram-single-path*.svg` to http://fontello.com service!
Use `telegram-source-240px.svg` as source file.
View CantSave.php
<?php
namespace common\exception;
use e96\sentry\ErrorHandler;
use yii\base\Exception;
use yii\db\ActiveRecord;
class CantSave extends Exception
View date_diff.php
<?php
$date1 = new \DateTime('2017-01-01');
$date2 = new \DateTime('2017-01-10');
$dateInterval = $date1->diff($date2); // this is not date1-date2, but date2-date1 :-(
var_dump($dateInterval->format('%r%a') > 3); // :-(
View WithoutTrait.php
<?php
namespace common\ActiveRecordTrait;
use yii\db\ActiveQuery;
use yii\db\ActiveRecord;
trait WithoutTrait
{
View OneInstance.php
<?php
namespace console\components;
use Yii;
use yii\base\ActionEvent;
use yii\base\Behavior;
use yii\base\Exception;
use yii\console\Controller;
View TruncateString.php
<?php
/**
* @param string $string Subject
* @param int $length Max string length
* @param bool $exactLength Truncate string with exact $length
* @param string $append Ellipsis string
* @return string
*/
class TruncateString
View ConsoleProgress.php
<?php
use yii\base\Object;
use yii\helpers\Console;
/**
* Usage:
* $consoleProgress = new ConsoleProgress(['max' => 365]);
* $consoleProgress->start();
* foreach($days in $day) {
View ExcelCsvWriter.php
<?php
/**
* require Yii2 for decimal formatter
*/
class ExcelCsvWriter
{
/**
* @var resource
*/
View SerializedFields.php
<?php
use yii\base\Behavior;
use yii\db\ActiveRecord;
class SerializedFields extends Behavior
{
/**
* @var ActiveRecord
*/