Skip to content

Instantly share code, notes, and snippets.

Eating the elephant in pieces

Dmitry Lezhnev lezhnev74

Eating the elephant in pieces
View GitHub Profile
lezhnev74 / MysqlCollection.php
Last active Nov 28, 2017
Cache in a collection implementation
View MysqlCollection.php
class MysqlCollection implements CollectionInterface
// .. other stuff
/** @var CacheInterface */
private $cache;
lezhnev74 / KnownProblem.php
Created Apr 8, 2017
Trait for translatable exceptions
View KnownProblem.php
namespace VideoPublisher\Foundation\Exception;
* This trait will add message translation to any exception.
* The goal of this is to support every exception with string problem code and possible message
trait KnownProblem
/** @var string code to look up in documentation like "112_EMAIL_INVALID" */
lezhnev74 / validator.php
Last active Mar 9, 2021
Replace custom placeholder in Validation message (Laravel)
View validator.php
// When I create a validation rule, I can set my one replacer which helps replace different special placeholders
// For example if validator message is "Problem with :some", then my replacer will handle it
Validator::extend('testrule', function($attribute, $value, $parameters, $validator) {
$validator->addReplacer('testrule', function($message, $attribute, $rule, $parameters){
return str_replace(":some", "whatever", $message);
View change validator UNIQUE rule depend on METHOD
public function rules()
$user = User::find($this->users);
case 'GET':
case 'DELETE':
return [];
View Another vagrant machine
So I am facing an Issue - how do I run dedicated Vagrant Virtual Machine with Homestead Box in it? shows how to run the box. But what about settings?
So I did:
vagrant init in folder
then installed Homstead via
composer require laravel/homestead --dev
php vendor/bin/homestead make
Then edited Homestead.yaml
and then did vagrant reload --provision so changes took effect