Skip to content

Instantly share code, notes, and snippets.

View crashkonijn's full-sized avatar

Peter Klooster crashkonijn

  • Netherlands
View GitHub Profile
@crashkonijn
crashkonijn / EloquentDirtyFix.php
Created May 11, 2018 09:34
Fixes the cast dirty problems in < Laravel 5.5 projects. Tested with L5.3
<?php
// TODO: remove when bug is fixed, https://github.com/laravel/framework/issues/8972
// Copied from the change that fixed it in 5.5: https://github.com/laravel/framework/pull/18400/files/01d6896cb402d7b641c84ed8d541b1bc96af34ce#diff-6a9cb621261ef4a702081454957adfb2
trait EloquentDirtyFix
{
public function getDirty()
{
$dirty = [];
foreach ($this->getAttributes() as $key => $value) {