Skip to content

Instantly share code, notes, and snippets.

@mediaash
Created September 19, 2017 16:23
Show Gist options
  • Save mediaash/772d243f790f7af6e6eb64fba882c781 to your computer and use it in GitHub Desktop.
Save mediaash/772d243f790f7af6e6eb64fba882c781 to your computer and use it in GitHub Desktop.
<?php
namespace MyApp\Model;
use Illuminate\Database\Eloquent\Model as EloquentModel;
use Illuminate\Support\Str;
/**
* Class CamelModel.
*
* @mixin \Illuminate\Database\Eloquent\Builder
*/
abstract class Model extends EloquentModel
{
public function getAttribute($key)
{
return parent::getAttribute(Str::snake($key));
}
public function setAttribute($key, $value)
{
return parent::setAttribute(Str::snake($key), $value);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment