Skip to content

Instantly share code, notes, and snippets.

View VictorFursa's full-sized avatar
🙃
Focusing

Victor Fursa VictorFursa

🙃
Focusing
View GitHub Profile
@VictorFursa
VictorFursa / PhoneHelper.php
Last active August 27, 2018 05:13
Laravel Phone Helper
'phone_number' => "required|unique:users,phone_number,$id|min:10|max:20",
protected function prepareForValidation()
{
$this->offsetSet('phone_number', PhoneHelper::normalize($this->phone_number));
}
<?php
<?php
namespace SadiSamBundle\DependencyInjection;
use SadiSamBundle\Menu\MenuInterface;
class ChainMenuItemProvider
{
private $menus;
class Cupon extends Model
{
/**
* Получить продукт где купон id связан.
*/
public function product()
{
return $this->belongsTo('App\Product');
}
}
@VictorFursa
VictorFursa / 1.txt
Created November 7, 2017 15:27
Ништяки
Terminal
если нужно найти недавно выполненную команду в истории, но помните только часть
`history | grep console` где `console` искомое слово,
выведет нумерованный список команд, находите нужную и запускаете ее по номеру `!541`
Symfony Console
если кому лень настраивать автокомплит команд для симфони, можно просто не писать полные команды, например
`bin/console c:c` равносильно `bin/console cache:clear`,
а `bin/console d:d:c` равносильно `bin/console doctrine:database:create`,
@VictorFursa
VictorFursa / arrayObject.php
Created October 19, 2017 22:36
create arrayObject
<?php
class Booked extends \yii\db\ActiveRecord
{
/** @var $sum integer */
public $sum;
/** @var $countBookedRoom integer */
public $countBookedRoom;
/** @var $countPayment integer */
public $countPayment;
/** @var $numberRoom integer */
@VictorFursa
VictorFursa / Closure.php
Created October 18, 2017 22:19
Closure
<?php
/** example */
$text = function (string $text) {
return $text;
};
$text('hello'); //return hello
$text = 'sum = ';
//в use можно передать несколько переменных function() use($var1, $var2) { }
@VictorFursa
VictorFursa / Static.php
Created October 18, 2017 21:42
static and self
<?php
class A
{
static public $name = 'zir4onah';
static public function name()
{
return static::$name;
@VictorFursa
VictorFursa / Active.php
Created October 9, 2017 21:55
позднее статическое связывание
<?php
namespace app\modules\admin\models;
use yii\db\ActiveRecord;
class Active extends ActiveRecord
{
public static function getDb()
{
<?php
final class Palindrome
{
/** @var string $string */
private $string;
/** @var string $oneLongString */
private $oneLongString;
<?php
abstract class Animal
{
/**
* @var Animal|string $name
*/
protected $name;
/**